Ejemplo n.º 1
0
    static void ShowResults(FrequencyArray freq, string heading, string xlabel)
    {
        Console.WriteLine("\n{0}\n", heading);
        Console.WriteLine("Max {0}: {1}", xlabel, freq.Value(freq.Length - 1));
        Stats stats = new Stats();

        stats.Calc(freq);
        Console.WriteLine("Sample size: {0}", stats.Size());
        Console.WriteLine("Average: {0}", stats.Average().ToStringMixed());
        Console.WriteLine("Median: {0}", stats.Median());
        Console.WriteLine("Mode: {0}", stats.Mode());
        Console.WriteLine("Standard Deviation: {0}", stats.StandardDeviation().ToStringMixed());
        display_graph(freq, xlabel, "Frequency");
    }
Ejemplo n.º 2
0
    static void display_graph(FrequencyArray freq_data, string xlabel, string ylabel)
    {
        // Determine scale for graph
        int    i;
        double scale = (double)teminal_cols / (double)freq_data.MaxFreq;

        Console.WriteLine("\n{0}|                 {1}", xlabel, ylabel);
        Console.WriteLine(new String('-', teminal_cols + 6));
        for (i = 0; i < freq_data.Length; i++)
        {
            string bar = new String('#', (int)Math.Round(freq_data.Frequency(i) * scale));
            Console.WriteLine("{0}|{1} {2}", freq_data.Value(i), bar, freq_data.Frequency(i));
        }
        Console.WriteLine();
    }