using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Science.Statistics.BasicStatistics { public class DataForHistogram { public DataForHistogram() { } private List cif = new List(); public List ClassIntervalFrom { get { return cif; } } private List cit = new List(); public List ClassIntervalTo { get { return cit; } } private List cl = new List(); // word or discrete number public List Class { get { return cl; } } private List c = new List(); public List Count { get { return c; } } public void Add(double from, double to, double count) { cif.Add(from); cit.Add(to); c.Add(count); } public void Add(double from, double to, int count) { Add(from, to, (double)count); } public void Add(int from, int to, double count) { Add((double)from, (double)to, count); } public void Add(int from, int to, int count) { Add((double)from, (double)to, (double)count); } public void Add(string word, double count) { cl.Add(word); c.Add(count); } public void Add(string word, int count) { Add(word, (double)count); } private List p = new List(); public List Percentile { get { return p; } } private List w = new List(); public List Width { get { return w; } } private List h = new List(); public List Height { get { return h; } } public void FindBars() { double sum = 0.0; for (int i = 0; i < c.Count; i++) { sum += c[i]; if (cl.Count == 0) w.Add(cit[i] - cif[i]); else w.Add(1.0); } for (int i = 0; i < c.Count; i++) { p.Add(c[i] / sum * 100.0); h.Add(c[i] / sum * 100.0 / w[i]); } } } }