SEEUMiner.Library.DescriptiveStatistics.StandardDeviationS C# (CSharp) Method

StandardDeviationS() public method

public StandardDeviationS ( ) : double
return double
        public double StandardDeviationS()
        {
            double mean = Average();
            double sum = 0.0d;
            for (int i = 0; i < array_items.Length; i++)
            {
                sum = sum + Math.Pow(array_items[i] - mean, 2);
            }

            double STDev_S = Math.Sqrt(sum / array_items.Length - 1);

            if (Double.IsNaN(STDev_S))
                return 0;

            return STDev_S;
        }

Usage Example

コード例 #1
0
ファイル: Form1.cs プロジェクト: vshehu/SEEUMiner
        private void button1_Click(object sender, EventArgs e)
        {
            string[] array = txtItems.Text.Split(',');

            double[] dArray = Array.ConvertAll(array, Double.Parse);

            DescriptiveStatistics s = new DescriptiveStatistics(dArray);

            MessageBox.Show("Mesatarja: " + s.Average().ToString());

            MessageBox.Show("Median:" + s.Median().ToString());

            MessageBox.Show("STDEV_Population: " + s.StandardDeviationP().ToString());
            MessageBox.Show("STDEV_Sample: " + s.StandardDeviationS().ToString());

            //CategoricalStatistics s = new CategoricalStatistics(array);

            //foreach (KeyValuePair<object, int> kv in s.Frequency())
            //{
            //    MessageBox.Show(kv.Key.ToString() + " - " + kv.Value.ToString());

            //}

            // test test test
            CategoricalStatistics cs = new CategoricalStatistics(dArray);
               // MessageBox.Show(Convert.ToInt32( cs.CalculateMode()).ToString());

            foreach (KeyValuePair<object, int> kv in cs.CalculateMode())
            {
               // MessageBox.Show("Mode: " + kv.Key.ToString() + "=" + kv.Value.ToString());
                label1.Text = "Mode: " + kv.Key.ToString() + "=" + kv.Value.ToString();
            }
        }