コード例 #1
0
    public static void DrawProbabilityRange(this GraphPane panel, double maxX, List<double> ratios)
    {
      var skipCount = ratios.Count / 20;

      var keptRatios = ratios.Skip(skipCount).ToList().Take(ratios.Count - 2 * skipCount).ToList();

      if (keptRatios.Count > 1)
      {
        var mean = Statistics.Mean(keptRatios);
        var sd = Statistics.StandardDeviation(keptRatios);

        var nd = new Normal(mean, sd);

        PointPairList pplMean = new PointPairList();
        pplMean.Add(new PointPair(0, mean));
        pplMean.Add(new PointPair(maxX, mean));
        LineItem meanLine = panel.AddCurve(MyConvert.Format("Mean={0:0.0000}, Sigma={1:0.0000}", mean, sd), pplMean, Color.Red, SymbolType.None);
        meanLine.Line.IsVisible = true;

        var prob90range = nd.GetProb90Range();

        PointPairList pplMin90 = new PointPairList();
        pplMin90.Add(new PointPair(0, prob90range.First));
        pplMin90.Add(new PointPair(maxX, prob90range.First));
        LineItem min95Line = panel.AddCurve("90% Confidence", pplMin90, Color.Brown, SymbolType.None);
        min95Line.Line.IsVisible = true;

        PointPairList pplMax90 = new PointPairList();
        pplMax90.Add(new PointPair(0, prob90range.Second));
        pplMax90.Add(new PointPair(maxX, prob90range.Second));
        LineItem max95Line = panel.AddCurve("", pplMax90, Color.Brown, SymbolType.None);
        max95Line.Line.IsVisible = true;
      }
    }