public IActionResult OnGet() { if (!ModelState.IsValid) { return(Page()); } var samples = GetSamples(); var cdf = new CDF(samples); Percentile = cdf.Calculate(GetRandomVariable()); var cdfInv = new InverseCDF(samples); const double eps = .0001; for (var perc = 0.0; perc <= .95 + eps; perc += .05) { var inv = cdfInv.Calculate(perc); Percentiles.Add(inv); XAxis.Add(Convert.ToInt32(perc * 100)); } return(Page()); }
private void ClearOldPercentiles() { foreach (Line2D percentile in Percentiles) { percentile.IsVisible = false; line2DPool.Add(percentile); } Percentiles.Clear(); }
public int Rank(decimal value) { foreach (var perc in Percentiles) { if (value <= this.PercentilesValue[perc]) { return(perc); } } return(Percentiles.Max()); }
public void CalculatePercentilesTest() { List <long> count = new List <long>(); List <double> percentiles = new List <double>(); for (int i = 0; i < 100; ++i) { count.Add(1); percentiles.Add(((double)i + 1) / 100.0); } var res = Percentiles.CalculatePercentiles(count, percentiles.ToArray()); for (int i = 0; i < res.Length; ++i) { Assert.AreEqual(i + 1, res[i]); } }
public override string ToString() { return(String.Format("Date: {0} ", Date) + String.Format("Props: {0}, ", String.Join(", ", Props.Select(k => k.Key + ": " + k.Value))) + (Count.HasValue ? String.Format("Count: {0}, ", Count) : "") + (Sum.HasValue ? String.Format("Sum: {0}, ", Sum) : "") + (Min.HasValue ? String.Format("Min: {0}, ", Min) : "") + (Max.HasValue ? String.Format("Max: {0}, ", Max) : "") + (Avg.HasValue ? String.Format("Avg: {0}, ", Avg) : "") + (Percentiles != null ? String.Format("Percentiles: {0}, ", String.Join(", ", Percentiles.Select(p => p.Key + ": " + p.Value))) : "") + (DistributionGroups != null ? String.Format("DistributionGroups: {0}, ", String.Join(", ", DistributionGroups.Select(p => p.Key + ": " + p.Value))) : "")); }
public void Merge(ParameterValues parameterValues) { Values.AddRange(parameterValues.Values); Percentiles.AddRange(parameterValues.Percentiles); }
public void Clear() { Values.Clear(); Percentiles.Clear(); }