Browse Source

Fix examples

pull/225/merge
Christoph Ruegg 12 years ago
parent
commit
95050aef2f
  1. 49
      Examples.sln
  2. 2
      RELEASENOTES.md
  3. 5
      build.fsx
  4. 19
      src/Examples/ConsoleHelper.cs
  5. 30
      src/Examples/ContinuousDistributions/BetaDistribution.cs
  6. 20
      src/Examples/ContinuousDistributions/ChiDistribution.cs
  7. 20
      src/Examples/ContinuousDistributions/ChiSquareDistribution.cs
  8. 14
      src/Examples/ContinuousDistributions/ContinuousUniformDistribution.cs
  9. 21
      src/Examples/ContinuousDistributions/ErlangDistribution.cs
  10. 20
      src/Examples/ContinuousDistributions/ExponentialDistribution.cs
  11. 22
      src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs
  12. 14
      src/Examples/ContinuousDistributions/GammaDistribution.cs
  13. 20
      src/Examples/ContinuousDistributions/InverseGammaDistribution.cs
  14. 21
      src/Examples/ContinuousDistributions/LaplaceDistribution.cs
  15. 21
      src/Examples/ContinuousDistributions/LogNormalDistribution.cs
  16. 14
      src/Examples/ContinuousDistributions/NormalDistribution.cs
  17. 21
      src/Examples/ContinuousDistributions/ParetoDistribution.cs
  18. 20
      src/Examples/ContinuousDistributions/RayleighDistribution.cs
  19. 23
      src/Examples/ContinuousDistributions/StableDistribution.cs
  20. 20
      src/Examples/ContinuousDistributions/StudentTDistribution.cs
  21. 21
      src/Examples/ContinuousDistributions/TriangularDistribution.cs
  22. 20
      src/Examples/ContinuousDistributions/WeibullDistribution.cs
  23. 22
      src/Examples/DiscreteDistributions/BernoulliDistribution.cs
  24. 23
      src/Examples/DiscreteDistributions/BinomialDistribution.cs
  25. 19
      src/Examples/DiscreteDistributions/CategoricalDistribution.cs
  26. 45
      src/Examples/DiscreteDistributions/ConwayMaxwellPoissonDistribution.cs
  27. 24
      src/Examples/DiscreteDistributions/DiscreteUniformDistribution.cs
  28. 24
      src/Examples/DiscreteDistributions/GeometricDistribution.cs
  29. 17
      src/Examples/DiscreteDistributions/HypergeometricDistribution.cs
  30. 29
      src/Examples/DiscreteDistributions/NegativeBinomialDistribution.cs
  31. 22
      src/Examples/DiscreteDistributions/PoissonDistribution.cs
  32. 23
      src/Examples/DiscreteDistributions/ZipfDistribution.cs
  33. 8
      src/Examples/Examples.csproj
  34. 2
      src/FSharpExamples/FSharpExamples.fsproj

49
Examples.sln

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30501.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "src\Examples\Examples.csproj", "{8239A6FF-1EF3-4DA4-A860-95C392DD6899}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpExamples", "src\FSharpExamples\FSharpExamples.fsproj", "{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Numerics", "src\Numerics\Numerics.csproj", "{B7CAE5F4-A23F-4438-B5BE-41226618B695}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp", "src\FSharp\FSharp.fsproj", "{37E8E802-A354-4114-BFC1-6E1357DA605B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Release-Signed|Any CPU = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Release|Any CPU.Build.0 = Release|Any CPU
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{8239A6FF-1EF3-4DA4-A860-95C392DD6899}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Release|Any CPU.Build.0 = Release|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release|Any CPU.Build.0 = Release|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{B7CAE5F4-A23F-4438-B5BE-41226618B695}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Release|Any CPU.Build.0 = Release|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Release-Signed|Any CPU.ActiveCfg = Release-Signed|Any CPU
{37E8E802-A354-4114-BFC1-6E1357DA605B}.Release-Signed|Any CPU.Build.0 = Release-Signed|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

2
RELEASENOTES.md

@ -1,4 +1,4 @@
### 3.0.1 - 2014-06-22 ### 3.0.1 - 2014-06-24
* Patch release, fixing a bug in new Matrix.ToMatrixString and Vector.ToVectorString routines. * Patch release, fixing a bug in new Matrix.ToMatrixString and Vector.ToVectorString routines.
### 3.0.0 - 2014-06-21 ### 3.0.0 - 2014-06-21

5
build.fsx

@ -533,6 +533,11 @@ Target "PublishTag" (fun _ -> publishReleaseTag "Math.NET Numerics" "" packageVe
Target "NativePublishTag" (fun _ -> publishReleaseTag "Math.NET Numerics Native Providers" "native-" nativePackageVersion nativeReleaseNotes) Target "NativePublishTag" (fun _ -> publishReleaseTag "Math.NET Numerics Native Providers" "native-" nativePackageVersion nativeReleaseNotes)
Target "DataPublishTag" (fun _ -> publishReleaseTag "Math.NET Numerics Data Extensions" "data-" dataPackageVersion dataReleaseNotes) Target "DataPublishTag" (fun _ -> publishReleaseTag "Math.NET Numerics Data Extensions" "data-" dataPackageVersion dataReleaseNotes)
Target "PublishMirrors" (fun _ ->
let repo = "../mirror-numerics"
Git.CommandHelper.runSimpleGitCommand repo "remote update" |> printfn "%s"
Git.CommandHelper.runSimpleGitCommand repo "push mirrors" |> printfn "%s")
Target "PublishDocs" (fun _ -> Target "PublishDocs" (fun _ ->
let repo = "../mathnet-websites" let repo = "../mathnet-websites"
Git.Branches.pull repo "origin" "master" Git.Branches.pull repo "origin" "master"

19
src/Examples/ConsoleHelper.cs

@ -25,20 +25,22 @@
// </copyright> // </copyright>
using System; using System;
using System.Collections.Generic;
using System.Linq;
using MathNet.Numerics.Statistics; using MathNet.Numerics.Statistics;
namespace Examples namespace Examples
{ {
/// <summary> /// <summary>
/// Helper fucntions to output into Console window /// Helper functions to output into Console window
/// </summary> /// </summary>
public static class ConsoleHelper public static class ConsoleHelper
{ {
/// <summary> /// <summary>
/// Disoplay histogram from the array /// Display histogram from the array
/// </summary> /// </summary>
/// <param name="data">Source array</param> /// <param name="data">Source array</param>
public static void DisplayHistogram(double[] data) public static void DisplayHistogram(IEnumerable<double> data)
{ {
var blockSymbol = Convert.ToChar(9608); var blockSymbol = Convert.ToChar(9608);
@ -48,7 +50,7 @@ namespace Examples
var histogram = new Histogram(data, rowMaxLength); var histogram = new Histogram(data, rowMaxLength);
// Find the absolute peak // Find the absolute peak
var maxBucketCount = 0.0; var maxBucketCount = 0.0;
for (var i = 0; i < histogram.BucketCount; i++) for (var i = 0; i < histogram.BucketCount; i++)
{ {
@ -105,5 +107,14 @@ namespace Examples
Console.WriteLine(); Console.WriteLine();
} }
/// <summary>
/// Display histogram from the array
/// </summary>
/// <param name="data">Source array</param>
public static void DisplayHistogram(IEnumerable<int> data)
{
DisplayHistogram(data.Select(x => (double)x));
}
} }
} }

30
src/Examples/ContinuousDistributions/BetaDistribution.cs

@ -118,47 +118,25 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Beta(5, 1) distribution and display histogram // 4. Generate 100000 samples of the Beta(5, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Beta(5, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Beta(5, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Beta.Samples(data, 5, 1);
{
data[i] = beta.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Beta(2, 5) distribution and display histogram // 5. Generate 100000 samples of the Beta(2, 5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Beta(2, 5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Beta(2, 5) distribution and display histogram");
beta.A = 2; Beta.Samples(data, 2, 5);
beta.B = 5;
for (var i = 0; i < data.Length; i++)
{
data[i] = beta.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Beta distribution and display histogram // 6. Generate 100000 samples of the Beta distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Beta(0.5, 0.5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Beta(0.5, 0.5) distribution and display histogram");
beta.A = 0.5; Beta.Samples(data, 0.5, 0.5);
beta.B = 0.5;
for (var i = 0; i < data.Length; i++)
{
data[i] = beta.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 7. Generate 100000 samples of the Beta distribution and display histogram // 7. Generate 100000 samples of the Beta distribution and display histogram
Console.WriteLine(@"7. Generate 100000 samples of the Beta(2, 2) distribution and display histogram"); Console.WriteLine(@"7. Generate 100000 samples of the Beta(2, 2) distribution and display histogram");
beta.A = 2; Beta.Samples(data, 2, 2);
beta.B = 2;
for (var i = 0; i < data.Length; i++)
{
data[i] = beta.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/ChiDistribution.cs

@ -118,33 +118,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Chi(1) distribution and display histogram // 4. Generate 100000 samples of the Chi(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Chi(1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Chi(1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Chi.Samples(data, 1);
{
data[i] = chi.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Chi(2) distribution and display histogram // 5. Generate 100000 samples of the Chi(2) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Chi(2) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Chi(2) distribution and display histogram");
chi.DegreesOfFreedom = 2; Chi.Samples(data, 2);
for (var i = 0; i < data.Length; i++)
{
data[i] = chi.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Chi(5) distribution and display histogram // 6. Generate 100000 samples of the Chi(5) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Chi(5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Chi(5) distribution and display histogram");
chi.DegreesOfFreedom = 5; Chi.Samples(data, 5);
for (var i = 0; i < data.Length; i++)
{
data[i] = chi.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/ChiSquareDistribution.cs

@ -121,33 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the ChiSquare(1) distribution and display histogram // 4. Generate 100000 samples of the ChiSquare(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the ChiSquare(1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the ChiSquare(1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) ChiSquared.Samples(data, 1);
{
data[i] = chiSquare.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the ChiSquare(4) distribution and display histogram // 5. Generate 100000 samples of the ChiSquare(4) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the ChiSquare(4) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the ChiSquare(4) distribution and display histogram");
chiSquare.DegreesOfFreedom = 4; ChiSquared.Samples(data, 4);
for (var i = 0; i < data.Length; i++)
{
data[i] = chiSquare.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the ChiSquare(8) distribution and display histogram // 6. Generate 100000 samples of the ChiSquare(8) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the ChiSquare(8) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the ChiSquare(8) distribution and display histogram");
chiSquare.DegreesOfFreedom = 8; ChiSquared.Samples(data, 8);
for (var i = 0; i < data.Length; i++)
{
data[i] = chiSquare.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

14
src/Examples/ContinuousDistributions/ContinuousUniformDistribution.cs

@ -121,23 +121,13 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the ContinuousUniform(0, 1) distribution and display histogram // 4. Generate 100000 samples of the ContinuousUniform(0, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the ContinuousUniform(0, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the ContinuousUniform(0, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) ContinuousUniform.Samples(data, 0.0, 1.0);
{
data[i] = continuousUniform.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the ContinuousUniform(2, 10) distribution and display histogram // 5. Generate 100000 samples of the ContinuousUniform(2, 10) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the ContinuousUniform(2, 10) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the ContinuousUniform(2, 10) distribution and display histogram");
continuousUniform.UpperBound = 10; ContinuousUniform.Samples(data, 2, 10);
continuousUniform.LowerBound = 2;
for (var i = 0; i < data.Length; i++)
{
data[i] = continuousUniform.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

21
src/Examples/ContinuousDistributions/ErlangDistribution.cs

@ -118,34 +118,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram // 4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Erlang(1, 2.0) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Erlang.Samples(data, 1, 2.0);
{
data[i] = erlang.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram // 5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram");
erlang.Shape = 3; Erlang.Samples(data, 3, 2.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = erlang.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram // 6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram");
erlang.Shape = 9; Erlang.Samples(data, 9, 0.5);
erlang.Scale = 0.5;
for (var i = 0; i < data.Length; i++)
{
data[i] = erlang.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/ExponentialDistribution.cs

@ -121,33 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Exponential(1) distribution and display histogram // 4. Generate 100000 samples of the Exponential(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Exponential(1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Exponential(1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Exponential.Samples(data, 1.0);
{
data[i] = exponential.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Exponential(9) distribution and display histogram // 5. Generate 100000 samples of the Exponential(9) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Exponential(9) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Exponential(9) distribution and display histogram");
exponential.Rate = 9; Exponential.Samples(data, 9.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = exponential.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Exponential(0.01) distribution and display histogram // 6. Generate 100000 samples of the Exponential(0.01) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Exponential(0.01) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Exponential(0.01) distribution and display histogram");
exponential.Rate = 0.01; Exponential.Samples(data, 0.01);
for (var i = 0; i < data.Length; i++)
{
data[i] = exponential.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

22
src/Examples/ContinuousDistributions/FisherSnedecorDistribution.cs

@ -115,35 +115,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the FisherSnedecor(50, 20) distribution and display histogram // 4. Generate 100000 samples of the FisherSnedecor(50, 20) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the FisherSnedecor(50, 20) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the FisherSnedecor(50, 20) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) FisherSnedecor.Samples(data, 50, 20);
{
data[i] = fisherSnedecor.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram // 5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the FisherSnedecor(20, 10) distribution and display histogram");
fisherSnedecor.DegreesOfFreedom1 = 20; FisherSnedecor.Samples(data, 20, 10);
fisherSnedecor.DegreesOfFreedom2 = 10;
for (var i = 0; i < data.Length; i++)
{
data[i] = fisherSnedecor.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram // 6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the FisherSnedecor(100, 100) distribution and display histogram");
fisherSnedecor.DegreesOfFreedom1 = 100; FisherSnedecor.Samples(data, 100, 100);
fisherSnedecor.DegreesOfFreedom2 = 100;
for (var i = 0; i < data.Length; i++)
{
data[i] = fisherSnedecor.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

14
src/Examples/ContinuousDistributions/GammaDistribution.cs

@ -118,23 +118,13 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Gamma(1, 2) distribution and display histogram // 4. Generate 100000 samples of the Gamma(1, 2) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Gamma(1, 2) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Gamma(1, 2) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Gamma.Samples(data, 1, 2);
{
data[i] = gamma.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Gamma(8) distribution and display histogram // 5. Generate 100000 samples of the Gamma(8) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Gamma(5, 1) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Gamma(5, 1) distribution and display histogram");
gamma.Shape = 5; Gamma.Samples(data, 5, 1);
gamma.Scale = 1;
for (var i = 0; i < data.Length; i++)
{
data[i] = gamma.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/InverseGammaDistribution.cs

@ -118,33 +118,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the InverseGamma(4, 0.5) distribution and display histogram // 4. Generate 100000 samples of the InverseGamma(4, 0.5) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the InverseGamma(4, 0.5) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the InverseGamma(4, 0.5) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) InverseGamma.Samples(data, 4, 0.5);
{
data[i] = inverseGamma.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the InverseGamma(8, 0.5) distribution and display histogram // 5. Generate 100000 samples of the InverseGamma(8, 0.5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the InverseGamma(8, 0.5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the InverseGamma(8, 0.5) distribution and display histogram");
inverseGamma.Shape = 8; InverseGamma.Samples(data, 8, 0.5);
for (var i = 0; i < data.Length; i++)
{
data[i] = inverseGamma.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the InverseGamma(2, 1) distribution and display histogram // 6. Generate 100000 samples of the InverseGamma(2, 1) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the InverseGamma(8, 2) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the InverseGamma(8, 2) distribution and display histogram");
inverseGamma.Scale = 2; InverseGamma.Samples(data, 8, 2);
for (var i = 0; i < data.Length; i++)
{
data[i] = inverseGamma.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

21
src/Examples/ContinuousDistributions/LaplaceDistribution.cs

@ -121,34 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Laplace(0, 1) distribution and display histogram // 4. Generate 100000 samples of the Laplace(0, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Laplace(0, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Laplace(0, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Laplace.Samples(data, 0.0, 1.0);
{
data[i] = laplace.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Laplace(0, 4) distribution and display histogram // 5. Generate 100000 samples of the Laplace(0, 4) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Laplace(0, 4) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Laplace(0, 4) distribution and display histogram");
data = new double[100000]; Laplace.Samples(data, 0.0, 4.0);
laplace.Scale = 4;
for (var i = 0; i < data.Length; i++)
{
data[i] = laplace.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Laplace(-10, 4) distribution and display histogram // 6. Generate 100000 samples of the Laplace(-10, 4) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Laplace(-10 4) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Laplace(-10 4) distribution and display histogram");
laplace.Location = -10; Laplace.Samples(data, -10.0, 4.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = laplace.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

21
src/Examples/ContinuousDistributions/LogNormalDistribution.cs

@ -121,34 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram // 4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the LogNormal(0, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) LogNormal.Samples(data, 0.0, 1.0);
{
data[i] = logNormal.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram // 5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the LogNormal(0, 0.5) distribution and display histogram");
logNormal.Sigma = 0.5; LogNormal.Samples(data, 0.0, 0.5);
for (var i = 0; i < data.Length; i++)
{
data[i] = logNormal.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram // 6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the LogNormal(5, 0.25) distribution and display histogram");
logNormal.Mu = 5; LogNormal.Samples(data, 5.0, 0.25);
logNormal.Sigma = 0.25;
for (var i = 0; i < data.Length; i++)
{
data[i] = logNormal.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

14
src/Examples/ContinuousDistributions/NormalDistribution.cs

@ -121,23 +121,13 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Normal(0, 1) distribution and display histogram // 4. Generate 100000 samples of the Normal(0, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Normal(0, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Normal(0, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Normal.Samples(data, 0.0, 1.0);
{
data[i] = normal.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Normal(-10, 0.2) distribution and display histogram // 5. Generate 100000 samples of the Normal(-10, 0.2) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Normal(-10, 0.01) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Normal(-10, 0.01) distribution and display histogram");
normal.Mean = -10; Normal.Samples(data, -10.0, 0.01);
normal.StdDev = 0.01;
for (var i = 0; i < data.Length; i++)
{
data[i] = normal.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

21
src/Examples/ContinuousDistributions/ParetoDistribution.cs

@ -121,34 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram // 4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Pareto.Samples(data, 1.0, 3.0);
{
data[i] = pareto.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram // 5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram");
pareto.Shape = 1; Pareto.Samples(data, 1.0, 1.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = pareto.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Pareto(10, 5) distribution and display histogram // 6. Generate 100000 samples of the Pareto(10, 5) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Pareto(10, 50) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Pareto(10, 50) distribution and display histogram");
pareto.Shape = 50; Pareto.Samples(data, 10.0, 50.0);
pareto.Scale = 10;
for (var i = 0; i < data.Length; i++)
{
data[i] = pareto.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/RayleighDistribution.cs

@ -121,33 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Rayleigh(1) distribution and display histogram // 4. Generate 100000 samples of the Rayleigh(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Rayleigh(1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Rayleigh(1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Rayleigh.Samples(data, 1.0);
{
data[i] = rayleigh.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Rayleigh(4) distribution and display histogram // 5. Generate 100000 samples of the Rayleigh(4) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Rayleigh(4) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Rayleigh(4) distribution and display histogram");
rayleigh.Scale = 4; Rayleigh.Samples(data, 4.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = rayleigh.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram // 6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram");
rayleigh.Scale = 0.5; Rayleigh.Samples(data, 0.5);
for (var i = 0; i < data.Length; i++)
{
data[i] = rayleigh.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

23
src/Examples/ContinuousDistributions/StableDistribution.cs

@ -118,36 +118,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Stable(1) distribution and display histogram // 4. Generate 100000 samples of the Stable(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Stable(2, 0, 1, 0) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Stable(2, 0, 1, 0) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Stable.Samples(data, 2, 0, 1, 0);
{
data[i] = stable.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Stable(1, 0, 1, 0) distribution and display histogram // 5. Generate 100000 samples of the Stable(1, 0, 1, 0) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Stable(1, 0, 1, 0) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Stable(1, 0, 1, 0) distribution and display histogram");
stable.Alpha = 1; Stable.Samples(data, 1, 0, 1, 0);
for (var i = 0; i < data.Length; i++)
{
data[i] = stable.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Stable(1.5, 1, 1, 5) distribution and display histogram // 6. Generate 100000 samples of the Stable(1.5, 1, 1, 5) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Stable(1.5, 1, 1, 5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Stable(1.5, 1, 1, 5) distribution and display histogram");
stable.Alpha = 1.5; Stable.Samples(data, 1.5, 1, 1, 5);
stable.Beta = 1;
stable.Location = 5;
stable.Scale = 5;
for (var i = 0; i < data.Length; i++)
{
data[i] = stable.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/StudentTDistribution.cs

@ -117,32 +117,18 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the StudentT(0, 1, 1) distribution and display histogram // 4. Generate 100000 samples of the StudentT(0, 1, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the StudentT(0, 1, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the StudentT(0, 1, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) StudentT.Samples(data, 0, 1, 1);
{
data[i] = studentT.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
// 5. Generate 100000 samples of the StudentT(0, 1, 5) distribution and display histogram // 5. Generate 100000 samples of the StudentT(0, 1, 5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the StudentT(0, 1, 5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the StudentT(0, 1, 5) distribution and display histogram");
studentT.DegreesOfFreedom = 5; StudentT.Samples(data, 0, 1, 5);
for (var i = 0; i < data.Length; i++)
{
data[i] = studentT.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the StudentT(0, 1, 10) distribution and display histogram // 6. Generate 100000 samples of the StudentT(0, 1, 10) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the StudentT(0, 1, 10) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the StudentT(0, 1, 10) distribution and display histogram");
studentT.DegreesOfFreedom = 10; StudentT.Samples(data, 0, 1, 10);
for (var i = 0; i < data.Length; i++)
{
data[i] = studentT.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

21
src/Examples/ContinuousDistributions/TriangularDistribution.cs

@ -63,7 +63,7 @@ namespace Examples.ContinuousDistributionsExamples
/// <a href="https://en.wikipedia.org/wiki/Triangular_distribution">Triangular distribution</a> /// <a href="https://en.wikipedia.org/wiki/Triangular_distribution">Triangular distribution</a>
public void Run() public void Run()
{ {
// 1. Initialize // 1. Initialize
var triangular = new Triangular(0, 1, 0.3); var triangular = new Triangular(0, 1, 0.3);
Console.WriteLine(@"1. Initialize the new instance of the Triangular distribution class with parameters Lower = {0}, Upper = {1}, Mode = {2}", triangular.LowerBound, triangular.UpperBound, triangular.Mode); Console.WriteLine(@"1. Initialize the new instance of the Triangular distribution class with parameters Lower = {0}, Upper = {1}, Mode = {2}", triangular.LowerBound, triangular.UpperBound, triangular.Mode);
Console.WriteLine(); Console.WriteLine();
@ -119,26 +119,15 @@ namespace Examples.ContinuousDistributionsExamples
Console.WriteLine(); Console.WriteLine();
// 10000 samples with starting parameters // 10000 samples with starting parameters
Console.WriteLine(@"4. Generate 100000 samples of the Triangular({0}, {1}, {2}) distribution and display histogram", triangular.LowerBound, triangular.UpperBound, triangular.Mode); Console.WriteLine(@"4. Generate 100000 samples of the Triangular(0, 1, 0.3) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Triangular.Samples(data, 0.0, 1.0, 0.3);
{
data[i] = triangular.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 10000 with different parameters // 10000 with different parameters
triangular.UpperBound = 10; Console.WriteLine(@"4. Generate 100000 samples of the Triangular(2, 10, 8) distribution and display histogram");
triangular.Mode = 8; Triangular.Samples(data, 2.0, 10.0, 8.0);
triangular.LowerBound = 2;
Console.WriteLine(@"4. Generate 100000 samples of the Triangular({0}, {1}, {2}) distribution and display histogram", triangular.LowerBound, triangular.UpperBound, triangular.Mode);
for (var i = 0; i < data.Length; i++)
{
data[i] = triangular.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

20
src/Examples/ContinuousDistributions/WeibullDistribution.cs

@ -121,33 +121,19 @@ namespace Examples.ContinuousDistributionsExamples
// 4. Generate 100000 samples of the Weibull(0.5, 1) distribution and display histogram // 4. Generate 100000 samples of the Weibull(0.5, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Weibull(0.5, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Weibull(0.5, 1) distribution and display histogram");
var data = new double[100000]; var data = new double[100000];
for (var i = 0; i < data.Length; i++) Weibull.Samples(data, 0.5, 1.0);
{
data[i] = weibull.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Weibull(1.5, 1) distribution and display histogram // 5. Generate 100000 samples of the Weibull(1.5, 1) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Weibull(1.5, 1) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Weibull(1.5, 1) distribution and display histogram");
weibull.Shape = 1.5; Weibull.Samples(data, 1.5, 1.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = weibull.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Weibull(5, 1) distribution and display histogram // 6. Generate 100000 samples of the Weibull(5, 1) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Weibull(5, 1) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Weibull(5, 1) distribution and display histogram");
weibull.Shape = 5; Weibull.Samples(data, 5.0, 1.0);
for (var i = 0; i < data.Length; i++)
{
data[i] = weibull.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

22
src/Examples/DiscreteDistributions/BernoulliDistribution.cs

@ -117,34 +117,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the Bernoulli(0.2) distribution and display histogram // 4. Generate 100000 samples of the Bernoulli(0.2) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Bernoulli(0.2) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Bernoulli(0.2) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Bernoulli.Samples(data, 0.2);
{
data[i] = bernoulli.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Bernoulli(4) distribution and display histogram // 5. Generate 100000 samples of the Bernoulli(4) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Bernoulli(0.9) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Bernoulli(0.9) distribution and display histogram");
bernoulli.P = 0.9; Bernoulli.Samples(data, 0.9);
for (var i = 0; i < data.Length; i++)
{
data[i] = bernoulli.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Bernoulli(8) distribution and display histogram // 6. Generate 100000 samples of the Bernoulli(8) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Bernoulli(0.5) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Bernoulli(0.5) distribution and display histogram");
bernoulli.P = 0.5; Bernoulli.Samples(data, 0.5);
for (var i = 0; i < data.Length; i++)
{
data[i] = bernoulli.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

23
src/Examples/DiscreteDistributions/BinomialDistribution.cs

@ -120,35 +120,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the Binomial(0.2, 20) distribution and display histogram // 4. Generate 100000 samples of the Binomial(0.2, 20) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Binomial(0.2, 20) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Binomial(0.2, 20) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Binomial.Samples(data, 0.2, 20);
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Binomial(0.7, 20) distribution and display histogram // 5. Generate 100000 samples of the Binomial(0.7, 20) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Binomial(0.7, 20) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Binomial(0.7, 20) distribution and display histogram");
binomial.P = 0.7; Binomial.Samples(data, 0.7, 20);
for (var i = 0; i < data.Length; i++)
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Binomial(0.5, 40) distribution and display histogram // 6. Generate 100000 samples of the Binomial(0.5, 40) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Binomial(0.5, 40) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Binomial(0.5, 40) distribution and display histogram");
binomial.P = 0.5; Binomial.Samples(data, 0.5, 40);
binomial.N = 40;
for (var i = 0; i < data.Length; i++)
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

19
src/Examples/DiscreteDistributions/CategoricalDistribution.cs

@ -111,24 +111,15 @@ namespace Examples.DiscreteDistributionsExamples
Console.WriteLine(); Console.WriteLine();
// 4. Generate 100000 samples of the Categorical(new []{ 0.1, 0.2, 0.25, 0.45 }) distribution and display histogram // 4. Generate 100000 samples of the Categorical(new []{ 0.1, 0.2, 0.25, 0.45 }) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Categorical(0.2, 20) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Categorical(0.1, 0.2, 0.25, 0.45) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Categorical.Samples(data, new[] { 0.1, 0.2, 0.25, 0.45 });
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Categorical(new []{ 0.6, 0.2, 0.1, 0.1 }) distribution and display histogram // 5. Generate 100000 samples of the Categorical(new []{ 0.6, 0.2, 0.1, 0.1 }) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Categorical(0.7, 20) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Categorical(0.6, 0.2, 0.1, 0.1) distribution and display histogram");
binomial.P = new[] { 0.6, 0.2, 0.1, 0.1 }; Categorical.Samples(data, new[] { 0.6, 0.2, 0.1, 0.1 });
for (var i = 0; i < data.Length; i++)
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

45
src/Examples/DiscreteDistributions/ConwayMaxwellPoissonDistribution.cs

@ -63,40 +63,40 @@ namespace Examples.DiscreteDistributionsExamples
public void Run() public void Run()
{ {
// 1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = 2, Nu = 1 // 1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = 2, Nu = 1
var binomial = new ConwayMaxwellPoisson(2, 1); var conwayMaxwellPoisson = new ConwayMaxwellPoisson(2, 1);
Console.WriteLine(@"1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = {0}, Nu = {1}", binomial.Lambda, binomial.Nu); Console.WriteLine(@"1. Initialize the new instance of the ConwayMaxwellPoisson distribution class with parameters Lambda = {0}, Nu = {1}", conwayMaxwellPoisson.Lambda, conwayMaxwellPoisson.Nu);
Console.WriteLine(); Console.WriteLine();
// 2. Distributuion properties: // 2. Distributuion properties:
Console.WriteLine(@"2. {0} distributuion properties:", binomial); Console.WriteLine(@"2. {0} distributuion properties:", conwayMaxwellPoisson);
// Cumulative distribution function // Cumulative distribution function
Console.WriteLine(@"{0} - Сumulative distribution at location '3'", binomial.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Сumulative distribution at location '3'", conwayMaxwellPoisson.CumulativeDistribution(3).ToString(" #0.00000;-#0.00000"));
// Probability density // Probability density
Console.WriteLine(@"{0} - Probability mass at location '3'", binomial.Probability(3).ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Probability mass at location '3'", conwayMaxwellPoisson.Probability(3).ToString(" #0.00000;-#0.00000"));
// Log probability density // Log probability density
Console.WriteLine(@"{0} - Log probability mass at location '3'", binomial.ProbabilityLn(3).ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Log probability mass at location '3'", conwayMaxwellPoisson.ProbabilityLn(3).ToString(" #0.00000;-#0.00000"));
// Smallest element in the domain // Smallest element in the domain
Console.WriteLine(@"{0} - Smallest element in the domain", binomial.Minimum.ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Smallest element in the domain", conwayMaxwellPoisson.Minimum.ToString(" #0.00000;-#0.00000"));
// Mean // Mean
Console.WriteLine(@"{0} - Mean", binomial.Mean.ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Mean", conwayMaxwellPoisson.Mean.ToString(" #0.00000;-#0.00000"));
// Variance // Variance
Console.WriteLine(@"{0} - Variance", binomial.Variance.ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Variance", conwayMaxwellPoisson.Variance.ToString(" #0.00000;-#0.00000"));
// Standard deviation // Standard deviation
Console.WriteLine(@"{0} - Standard deviation", binomial.StdDev.ToString(" #0.00000;-#0.00000")); Console.WriteLine(@"{0} - Standard deviation", conwayMaxwellPoisson.StdDev.ToString(" #0.00000;-#0.00000"));
Console.WriteLine(); Console.WriteLine();
// 3. Generate 10 samples of the ConwayMaxwellPoisson distribution // 3. Generate 10 samples of the ConwayMaxwellPoisson distribution
Console.WriteLine(@"3. Generate 10 samples of the ConwayMaxwellPoisson distribution"); Console.WriteLine(@"3. Generate 10 samples of the ConwayMaxwellPoisson distribution");
for (var i = 0; i < 10; i++) for (var i = 0; i < 10; i++)
{ {
Console.Write(binomial.Sample().ToString("N05") + @" "); Console.Write(conwayMaxwellPoisson.Sample().ToString("N05") + @" ");
} }
Console.WriteLine(); Console.WriteLine();
@ -104,35 +104,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the ConwayMaxwellPoisson(4, 1) distribution and display histogram // 4. Generate 100000 samples of the ConwayMaxwellPoisson(4, 1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the ConwayMaxwellPoisson(4, 1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the ConwayMaxwellPoisson(4, 1) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) ConwayMaxwellPoisson.Samples(data, 4, 1);
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the ConwayMaxwellPoisson(2, 1) distribution and display histogram // 5. Generate 100000 samples of the ConwayMaxwellPoisson(2, 1) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the ConwayMaxwellPoisson(2, 1) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the ConwayMaxwellPoisson(2, 1) distribution and display histogram");
binomial.Lambda = 2; ConwayMaxwellPoisson.Samples(data, 2, 1);
for (var i = 0; i < data.Length; i++)
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the ConwayMaxwellPoisson(5, 2) distribution and display histogram // 6. Generate 100000 samples of the ConwayMaxwellPoisson(5, 2) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the ConwayMaxwellPoisson(5, 2) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the ConwayMaxwellPoisson(5, 2) distribution and display histogram");
binomial.Lambda = 5; ConwayMaxwellPoisson.Samples(data, 5, 2);
binomial.Nu = 2;
for (var i = 0; i < data.Length; i++)
{
data[i] = binomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

24
src/Examples/DiscreteDistributions/DiscreteUniformDistribution.cs

@ -120,36 +120,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the DiscreteUniform(2, 10) distribution and display histogram // 4. Generate 100000 samples of the DiscreteUniform(2, 10) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the DiscreteUniform(2, 10) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the DiscreteUniform(2, 10) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) DiscreteUniform.Samples(data, 2, 10);
{
data[i] = discreteUniform.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the DiscreteUniform(-10, 10) distribution and display histogram // 5. Generate 100000 samples of the DiscreteUniform(-10, 10) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the DiscreteUniform(-10, 10) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the DiscreteUniform(-10, 10) distribution and display histogram");
discreteUniform.LowerBound = -10; DiscreteUniform.Samples(data, -10, 10);
discreteUniform.UpperBound = 10;
for (var i = 0; i < data.Length; i++)
{
data[i] = discreteUniform.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the DiscreteUniform(0, 40) distribution and display histogram // 6. Generate 100000 samples of the DiscreteUniform(0, 40) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the DiscreteUniform(0, 40) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the DiscreteUniform(0, 40) distribution and display histogram");
discreteUniform.LowerBound = 0; DiscreteUniform.Samples(data, 0, 40);
discreteUniform.UpperBound = 40;
for (var i = 0; i < data.Length; i++)
{
data[i] = discreteUniform.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

24
src/Examples/DiscreteDistributions/GeometricDistribution.cs

@ -119,35 +119,21 @@ namespace Examples.DiscreteDistributionsExamples
Console.WriteLine(); Console.WriteLine();
// 4. Generate 100000 samples of the Geometric(0.2, 20) distribution and display histogram // 4. Generate 100000 samples of the Geometric(0.2, 20) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Geometric(0.2, 20) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Geometric(0.2) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Geometric.Samples(data, 0.2);
{
data[i] = geometric.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Geometric(0.5) distribution and display histogram // 5. Generate 100000 samples of the Geometric(0.5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Geometric(0.5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Geometric(0.5) distribution and display histogram");
geometric.P = 0.5; Geometric.Samples(data, 0.5);
for (var i = 0; i < data.Length; i++)
{
data[i] = geometric.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Geometric(0.8) distribution and display histogram // 6. Generate 100000 samples of the Geometric(0.8) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Geometric(0.8) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Geometric(0.8) distribution and display histogram");
geometric.P = 0.8; Geometric.Samples(data, 0.8);
for (var i = 0; i < data.Length; i++)
{
data[i] = geometric.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

17
src/Examples/DiscreteDistributions/HypergeometricDistribution.cs

@ -114,25 +114,14 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the Hypergeometric(30, 15, 10) distribution and display histogram // 4. Generate 100000 samples of the Hypergeometric(30, 15, 10) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Hypergeometric(30, 15, 10) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Hypergeometric(30, 15, 10) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Hypergeometric.Samples(data, 30, 15, 10);
{
data[i] = hypergeometric.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Hypergeometric(52, 13, 5) distribution and display histogram // 5. Generate 100000 samples of the Hypergeometric(52, 13, 5) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Hypergeometric(52, 13, 5) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Hypergeometric(52, 13, 5) distribution and display histogram");
hypergeometric.Population = 52; Hypergeometric.Samples(data, 52, 13, 5);
hypergeometric.Success = 13;
hypergeometric.Draws = 5;
for (var i = 0; i < data.Length; i++)
{
data[i] = hypergeometric.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

29
src/Examples/DiscreteDistributions/NegativeBinomialDistribution.cs

@ -113,36 +113,21 @@ namespace Examples.DiscreteDistributionsExamples
Console.WriteLine(); Console.WriteLine();
// 4. Generate 100000 samples of the NegativeBinomial(0.2, 20) distribution and display histogram // 4. Generate 100000 samples of the NegativeBinomial(0.2, 20) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the NegativeBinomial(0.2, 20) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the NegativeBinomial(20, 0.2) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) NegativeBinomial.Samples(data, 20, 0.2);
{
data[i] = negativeBinomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the NegativeBinomial(0.7, 20) distribution and display histogram // 5. Generate 100000 samples of the NegativeBinomial(0.7, 20) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the NegativeBinomial(0.7, 20) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the NegativeBinomial(20, 0.7) distribution and display histogram");
negativeBinomial.P = 0.7; NegativeBinomial.Samples(data, 20, 0.7);
for (var i = 0; i < data.Length; i++)
{
data[i] = negativeBinomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the NegativeBinomial(0.5, 1) distribution and display histogram // 6. Generate 100000 samples of the NegativeBinomial(0.5, 1) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the NegativeBinomial(0.5, 1) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the NegativeBinomial(1, 0.5) distribution and display histogram");
negativeBinomial.P = 0.5; NegativeBinomial.Samples(data, 1, 0.5);
negativeBinomial.R = 1;
for (var i = 0; i < data.Length; i++)
{
data[i] = negativeBinomial.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

22
src/Examples/DiscreteDistributions/PoissonDistribution.cs

@ -120,34 +120,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the Poisson(1) distribution and display histogram // 4. Generate 100000 samples of the Poisson(1) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Poisson(1) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Poisson(1) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Poisson.Samples(data, 1);
{
data[i] = poisson.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Poisson(4) distribution and display histogram // 5. Generate 100000 samples of the Poisson(4) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Poisson(4) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Poisson(4) distribution and display histogram");
poisson.Lambda = 4; Poisson.Samples(data, 4);
for (var i = 0; i < data.Length; i++)
{
data[i] = poisson.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Poisson(10) distribution and display histogram // 6. Generate 100000 samples of the Poisson(10) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Poisson(10) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Poisson(10) distribution and display histogram");
poisson.Lambda = 10; Poisson.Samples(data, 10);
for (var i = 0; i < data.Length; i++)
{
data[i] = poisson.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

23
src/Examples/DiscreteDistributions/ZipfDistribution.cs

@ -117,35 +117,20 @@ namespace Examples.DiscreteDistributionsExamples
// 4. Generate 100000 samples of the Zipf(5, 10) distribution and display histogram // 4. Generate 100000 samples of the Zipf(5, 10) distribution and display histogram
Console.WriteLine(@"4. Generate 100000 samples of the Zipf(5, 10) distribution and display histogram"); Console.WriteLine(@"4. Generate 100000 samples of the Zipf(5, 10) distribution and display histogram");
var data = new double[100000]; var data = new int[100000];
for (var i = 0; i < data.Length; i++) Zipf.Samples(data, 5, 10);
{
data[i] = zipf.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 5. Generate 100000 samples of the Zipf(2, 10) distribution and display histogram // 5. Generate 100000 samples of the Zipf(2, 10) distribution and display histogram
Console.WriteLine(@"5. Generate 100000 samples of the Zipf(2, 10) distribution and display histogram"); Console.WriteLine(@"5. Generate 100000 samples of the Zipf(2, 10) distribution and display histogram");
zipf.S = 2; Zipf.Samples(data, 2, 10);
for (var i = 0; i < data.Length; i++)
{
data[i] = zipf.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
Console.WriteLine(); Console.WriteLine();
// 6. Generate 100000 samples of the Zipf(5, 20) distribution and display histogram // 6. Generate 100000 samples of the Zipf(5, 20) distribution and display histogram
Console.WriteLine(@"6. Generate 100000 samples of the Zipf(1, 20) distribution and display histogram"); Console.WriteLine(@"6. Generate 100000 samples of the Zipf(1, 20) distribution and display histogram");
zipf.S = 1; Zipf.Samples(data, 1, 20);
zipf.N = 20;
for (var i = 0; i < data.Length; i++)
{
data[i] = zipf.Sample();
}
ConsoleHelper.DisplayHistogram(data); ConsoleHelper.DisplayHistogram(data);
} }
} }

8
src/Examples/Examples.csproj

@ -172,15 +172,15 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Numerics\Numerics.csproj"> <ProjectReference Include="..\Numerics\Numerics.csproj">
<Project>{B7CAE5F4-A23F-4438-B5BE-41226618B695}</Project> <Project>{b7cae5f4-a23f-4438-b5be-41226618b695}</Project>
<Name>Numerics</Name> <Name>Numerics</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

2
src/FSharpExamples/FSharpExamples.fsproj

@ -70,6 +70,8 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Numerics" /> <Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FSharp\FSharp.fsproj"> <ProjectReference Include="..\FSharp\FSharp.fsproj">
<Name>FSharp</Name> <Name>FSharp</Name>
<Project>{37e8e802-a354-4114-bfc1-6e1357da605b}</Project> <Project>{37e8e802-a354-4114-bfc1-6e1357da605b}</Project>

Loading…
Cancel
Save