Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Source/Examples/ExampleLibrary/Series/HistogramSeriesExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public static PlotModel CreateExponentialDistribution(double mean = 1, int n = 1

var binningOptions = new BinningOptions(BinningOutlierMode.CountOutliers, BinningIntervalType.InclusiveLowerBound, BinningExtremeValueMode.ExcludeExtremeValues);
var binBreaks = HistogramHelpers.CreateUniformBins(0, 5, 15);
chs.Items.AddRange(HistogramHelpers.Collect(SampleExps(rnd, 1.0, n), binBreaks, binningOptions));
chs.Items.AddRange(HistogramHelpers.Collect(SampleExps(rnd, mean, n), binBreaks, binningOptions));
chs.StrokeThickness = 1;
model.Series.Add(chs);

Expand All @@ -137,12 +137,12 @@ public static PlotModel CreateExponentialDistributionCustomBins(double mean = 1,
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Frequency" });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "x" });

Random rnd = new Random();
Random rnd = new Random(1);

HistogramSeries chs = new HistogramSeries();

var binningOptions = new BinningOptions(BinningOutlierMode.CountOutliers, BinningIntervalType.InclusiveLowerBound, BinningExtremeValueMode.ExcludeExtremeValues);
chs.Items.AddRange(HistogramHelpers.Collect(SampleExps(rnd, 1.0, n), new double[] { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0 }, binningOptions));
chs.Items.AddRange(HistogramHelpers.Collect(SampleExps(rnd, mean, n), new double[] { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0 }, binningOptions));
chs.StrokeThickness = 1;
chs.FillColor = OxyColors.Purple;
model.Series.Add(chs);
Expand All @@ -156,7 +156,7 @@ public static PlotModel CreateNormalDistribution(double mean = 0, double std = 1
model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Title = "Frequency" });
model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Title = "x" });

Random rnd = new Random();
Random rnd = new Random(1);

HistogramSeries chs = new HistogramSeries();
var binningOptions = new BinningOptions(BinningOutlierMode.CountOutliers, BinningIntervalType.InclusiveLowerBound, BinningExtremeValueMode.ExcludeExtremeValues);
Expand Down Expand Up @@ -248,9 +248,9 @@ private static IEnumerable<double> SampleNormal(Random rnd, double mean, double
private static double SampleNormal(Random rnd, double mean, double std)
{
// http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
var u1 = rnd.NextDouble();
var u1 = 1.0 - rnd.NextDouble();
var u2 = rnd.NextDouble();
return Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2);
return Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2) * std + mean;
}

private static IEnumerable<double> SampleUniform(Random rnd, double min, double max, int count)
Expand Down