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(); } }
public double[] ZScore(double[] array_to_normalize) { //formula eshte: v-mesatarja / devijimi double average; double deviation; DescriptiveStatistics ds = new DescriptiveStatistics(array_to_normalize); average = ds.Average(); deviation = ds.StandardDeviationP(); List<double> normalized_array = new List<double>(); foreach (double element in array_to_normalize) { double new_value = (element - average) / deviation; normalized_array.Add(new_value); } return normalized_array.ToArray(); }
public double[] ZScore(double[] array_to_normalize) { //formula eshte: v-mesatarja / devijimi double average; double deviation; DescriptiveStatistics ds = new DescriptiveStatistics(array_to_normalize); average = ds.Average(); deviation = ds.StandardDeviationP(); List <double> normalized_array = new List <double>(); foreach (double element in array_to_normalize) { double new_value = (element - average) / deviation; normalized_array.Add(new_value); } return(normalized_array.ToArray()); }