Skip to content

Commit 2d00846

Browse files
authored
Fix mean value calculation for Uniform distribution (#43)
1 parent 27914f0 commit 2d00846

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/SimSharp/Random/Distributions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public class Uniform : Distribution<double> {
366366
public double Lower => _lower;
367367
public double Upper => _upper;
368368

369-
public double Mean => 0.5 * (_upper - _lower);
369+
public double Mean => 0.5 * (_lower + _upper);
370370
public double StdDev => Math.Sqrt((_upper - _lower) * (_upper - _lower) / 12.0);
371371

372372
public Uniform(double lower, double upperExclusive) {
@@ -390,7 +390,7 @@ public class UniformTime : Distribution<TimeSpan> {
390390

391391
public TimeSpan Lower => _lower;
392392
public TimeSpan Upper => _upper;
393-
public TimeSpan MeanTime => TimeSpan.FromSeconds(0.5 * (_upper - _lower).TotalSeconds);
393+
public TimeSpan MeanTime => TimeSpan.FromSeconds(0.5 * (_lower + _upper).TotalSeconds);
394394
public TimeSpan StdDevTime => TimeSpan.FromSeconds(Math.Sqrt((_upper - _lower).TotalSeconds * (_upper - _lower).TotalSeconds / 12.0));
395395

396396
public UniformTime(TimeSpan lower, TimeSpan upperExclusive) {

src/SimSharp/SimSharp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
55
<SignAssembly>True</SignAssembly>
66
<AssemblyOriginatorKeyFile>SimSharp.snk</AssemblyOriginatorKeyFile>
77
<DelaySign>False</DelaySign>
@@ -33,7 +33,7 @@ Sim# allows modeling processes easily and with little boiler plate code. A proce
3333
1) All of the RandXXX methods in class Simulation have been marked as obsolete.
3434
2) All of the random TimeoutXXX methods in class Simulation have been marked as obsolete.
3535

36-
To port code, it is advised to add &quot;using static SimSharp.Distributions&quot; to the using section and change e.g.
36+
To port code, it is advised to add "using static SimSharp.Distributions" to the using section and change e.g.
3737
env.RandUniform(1, 2) to env.Rand(UNIF(1, 2))
3838
env.RandNormalPositive(3, 0.5) to env.Rand(POS(N(3, 0.5)))
3939
env.RandLogNormal(1, 2) to env.Rand(LNORM(1, 2))

0 commit comments

Comments
 (0)