@@ -124,7 +124,7 @@ public static PlotModel CreateExponentialDistribution(double mean = 1, int n = 1
124124
125125 var binningOptions = new BinningOptions ( BinningOutlierMode . CountOutliers , BinningIntervalType . InclusiveLowerBound , BinningExtremeValueMode . ExcludeExtremeValues ) ;
126126 var binBreaks = HistogramHelpers . CreateUniformBins ( 0 , 5 , 15 ) ;
127- chs . Items . AddRange ( HistogramHelpers . Collect ( SampleExps ( rnd , 1.0 , n ) , binBreaks , binningOptions ) ) ;
127+ chs . Items . AddRange ( HistogramHelpers . Collect ( SampleExps ( rnd , mean , n ) , binBreaks , binningOptions ) ) ;
128128 chs . StrokeThickness = 1 ;
129129 model . Series . Add ( chs ) ;
130130
@@ -137,12 +137,12 @@ public static PlotModel CreateExponentialDistributionCustomBins(double mean = 1,
137137 model . Axes . Add ( new LinearAxis { Position = AxisPosition . Left , Title = "Frequency" } ) ;
138138 model . Axes . Add ( new LinearAxis { Position = AxisPosition . Bottom , Title = "x" } ) ;
139139
140- Random rnd = new Random ( ) ;
140+ Random rnd = new Random ( 1 ) ;
141141
142142 HistogramSeries chs = new HistogramSeries ( ) ;
143143
144144 var binningOptions = new BinningOptions ( BinningOutlierMode . CountOutliers , BinningIntervalType . InclusiveLowerBound , BinningExtremeValueMode . ExcludeExtremeValues ) ;
145- 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 ) ) ;
145+ 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 ) ) ;
146146 chs . StrokeThickness = 1 ;
147147 chs . FillColor = OxyColors . Purple ;
148148 model . Series . Add ( chs ) ;
@@ -156,7 +156,7 @@ public static PlotModel CreateNormalDistribution(double mean = 0, double std = 1
156156 model . Axes . Add ( new LinearAxis { Position = AxisPosition . Left , Title = "Frequency" } ) ;
157157 model . Axes . Add ( new LinearAxis { Position = AxisPosition . Bottom , Title = "x" } ) ;
158158
159- Random rnd = new Random ( ) ;
159+ Random rnd = new Random ( 1 ) ;
160160
161161 HistogramSeries chs = new HistogramSeries ( ) ;
162162 var binningOptions = new BinningOptions ( BinningOutlierMode . CountOutliers , BinningIntervalType . InclusiveLowerBound , BinningExtremeValueMode . ExcludeExtremeValues ) ;
@@ -248,9 +248,9 @@ private static IEnumerable<double> SampleNormal(Random rnd, double mean, double
248248 private static double SampleNormal ( Random rnd , double mean , double std )
249249 {
250250 // http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
251- var u1 = rnd . NextDouble ( ) ;
251+ var u1 = 1.0 - rnd . NextDouble ( ) ;
252252 var u2 = rnd . NextDouble ( ) ;
253- return Math . Sqrt ( - 2 * Math . Log ( u1 ) ) * Math . Cos ( 2 * Math . PI * u2 ) ;
253+ return Math . Sqrt ( - 2 * Math . Log ( u1 ) ) * Math . Cos ( 2 * Math . PI * u2 ) * std + mean ;
254254 }
255255
256256 private static IEnumerable < double > SampleUniform ( Random rnd , double min , double max , int count )
0 commit comments