Median() public method

public Median ( ) : double
return double
Exemplo n.º 1
0
        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();
            }
        }