diff --git a/examples/examples-csharp/examples-csharp.csproj b/examples/examples-csharp/examples-csharp.csproj
index 8898d938..04439903 100644
--- a/examples/examples-csharp/examples-csharp.csproj
+++ b/examples/examples-csharp/examples-csharp.csproj
@@ -1,22 +1,15 @@
+
net40;net45;net46;netstandard1.6;netstandard2.0
false
-
-
-
-
-
-
-
-
-
-
+
+
-
+
diff --git a/examples/examples-fsharp/Apply.fs b/examples/examples-fsharp/Apply.fs
new file mode 100644
index 00000000..0d2bba7f
--- /dev/null
+++ b/examples/examples-fsharp/Apply.fs
@@ -0,0 +1,55 @@
+module Apply
+
+open System.Numerics
+open MathNet.Numerics
+open MathNet.Numerics.Distributions
+open MathNet.Numerics.Random
+open MathNet.Numerics.LinearAlgebra
+open MathNet.Numerics.LinearAlgebra.Double
+
+/// The size of the vector we want to map things for.
+let N = 1000000
+
+/// The number of times we repeat a call.
+let T = 10
+
+/// The list of all functions we want to test.
+let FunctionList : (string * (float -> float)) [] =
+ [| ("Cosine", cos);
+ ("Sine", sin);
+ ("Tangent", tan);
+ ("Inverse Cosine", acos);
+ ("Inverse Sine", asin);
+ ("Inverse Tangent", atan);
+ ("Hyperbolic Cosine", cosh);
+ ("Hyperbolic Sine", sinh);
+ ("Hyperbolic Tangent", tanh);
+ ("Abs", abs);
+ ("Exp", exp);
+ ("Log", log);
+ ("Sqrt", sqrt);
+ ("Error Function", SpecialFunctions.Erf);
+ ("Error Function Complement", SpecialFunctions.Erfc);
+ ("Inverse Error Function", SpecialFunctions.ErfInv);
+ ("Inverse Error Function Complement", SpecialFunctions.ErfcInv) |]
+
+/// A vector with random entries.
+let w =
+ let dist = Normal(1.0, 10.0, Random.mersenneTwister ())
+ DenseVector.random N dist
+
+/// A stopwatch to time the execution.
+let sw = System.Diagnostics.Stopwatch()
+
+
+printfn "%d-dimensional vector for %d iterations:" N T
+
+for (name, f) in FunctionList do
+
+ let v = w.Clone()
+
+ sw.Restart()
+ for t in 1 .. T do Vector.mapInPlace f v
+ sw.Stop()
+
+ printfn "%s:\t\t%d ms" name sw.ElapsedMilliseconds
diff --git a/examples/examples-fsharp/Apply.fsx b/examples/examples-fsharp/Apply.fsx
deleted file mode 100644
index 4dd17f8f..00000000
--- a/examples/examples-fsharp/Apply.fsx
+++ /dev/null
@@ -1,86 +0,0 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
-
-open System.Numerics
-open MathNet.Numerics
-open MathNet.Numerics.Distributions
-open MathNet.Numerics.Random
-open MathNet.Numerics.LinearAlgebra.Double
-open MathNet.Numerics.LinearAlgebra.Generic
-
-/// The size of the vector we want to map things for.
-let N = 1000000
-
-/// The number of times we repeat a call.
-let T = 10
-
-/// The list of all functions we want to test.
-let FunctionList : (string * (float -> float)) [] =
- [| ("Cosine", cos);
- ("Sine", sin);
- ("Tangent", tan);
- ("Inverse Cosine", acos);
- ("Inverse Sine", asin);
- ("Inverse Tangent", atan);
- ("Hyperbolic Cosine", cosh);
- ("Hyperbolic Sine", sinh);
- ("Hyperbolic Tangent", tanh);
- ("Abs", abs);
- ("Exp", exp);
- ("Log", log);
- ("Sqrt", sqrt);
- ("Error Function", SpecialFunctions.Erf);
- ("Error Function Complement", SpecialFunctions.Erfc);
- ("Inverse Error Function", SpecialFunctions.ErfInv);
- ("Inverse Error Function Complement", SpecialFunctions.ErfcInv) |]
-
-/// A vector with random entries.
-let w =
- let dist = Normal(1.0, 10.0) |> withRandom (Random.mersenneTwister ())
- DenseVector.randomCreate N dist
-
-/// A stopwatch to time the execution.
-let sw = System.Diagnostics.Stopwatch()
-
-
-printfn "%d-dimensional vector for %d iterations:" N T
-
-for (name, f) in FunctionList do
-
- let v = w.Clone()
-
- sw.Restart()
- for t in 1 .. T do Vector.mapInPlace f v
- sw.Stop()
-
- printfn "%s:\t\t%d ms" name sw.ElapsedMilliseconds
diff --git a/examples/examples-fsharp/Histogram.fs b/examples/examples-fsharp/Histogram.fs
new file mode 100644
index 00000000..d3465f81
--- /dev/null
+++ b/examples/examples-fsharp/Histogram.fs
@@ -0,0 +1,17 @@
+module Histogram
+
+open MathNet.Numerics.Statistics
+
+/// The number of buckets to use in our histogram.
+let B = 4
+
+/// Create a small dataset.
+let data = [| 0.5; 1.5; 2.5; 3.5; 4.5; 5.5; 6.5; 7.5; 8.5; 9.5 |]
+
+/// A histogram with 4 buckets for this dataset.
+let hist = new Histogram(data, B)
+
+// Print some histogram information.
+printfn "Histogram.ToString(): %O" hist
+for i in 0 .. B-1 do
+ printfn "Bucket %d contains %f datapoints." i hist.[i].Count
diff --git a/examples/examples-fsharp/Histogram.fsx b/examples/examples-fsharp/Histogram.fsx
deleted file mode 100644
index b1dca295..00000000
--- a/examples/examples-fsharp/Histogram.fsx
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
-
-open MathNet.Numerics.Statistics
-
-/// The number of buckets to use in our histogram.
-let B = 4
-
-/// Create a small dataset.
-let data = [| 0.5; 1.5; 2.5; 3.5; 4.5; 5.5; 6.5; 7.5; 8.5; 9.5 |]
-
-/// A histogram with 4 buckets for this dataset.
-let hist = new Histogram(data, B)
-
-// Print some histogram information.
-printfn "Histogram.ToString(): %O" hist
-for i in 0 .. B-1 do
- printfn "Bucket %d contains %f datapoints." i hist.[i].Count
diff --git a/examples/examples-fsharp/LinearRegression.fsx b/examples/examples-fsharp/LinearRegression.fs
similarity index 55%
rename from examples/examples-fsharp/LinearRegression.fsx
rename to examples/examples-fsharp/LinearRegression.fs
index f4d35ed7..6715b519 100644
--- a/examples/examples-fsharp/LinearRegression.fsx
+++ b/examples/examples-fsharp/LinearRegression.fs
@@ -1,35 +1,4 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
+module LinearRegression
open System
open MathNet.Numerics
diff --git a/examples/examples-fsharp/MCMC.fsx b/examples/examples-fsharp/MCMC.fs
similarity index 81%
rename from examples/examples-fsharp/MCMC.fsx
rename to examples/examples-fsharp/MCMC.fs
index 6af2e21d..c1b7ce29 100644
--- a/examples/examples-fsharp/MCMC.fsx
+++ b/examples/examples-fsharp/MCMC.fs
@@ -1,35 +1,4 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
+module MCMC
open MathNet.Numerics
open MathNet.Numerics.Random
diff --git a/examples/examples-fsharp/Matrices.fsx b/examples/examples-fsharp/Matrices.fs
similarity index 70%
rename from examples/examples-fsharp/Matrices.fsx
rename to examples/examples-fsharp/Matrices.fs
index 25c894d0..1ca390bc 100644
--- a/examples/examples-fsharp/Matrices.fsx
+++ b/examples/examples-fsharp/Matrices.fs
@@ -1,35 +1,4 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
+module Matrices
open MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.LinearAlgebra.Double
diff --git a/examples/examples-fsharp/RandomAndDistributions.fsx b/examples/examples-fsharp/RandomAndDistributions.fs
similarity index 91%
rename from examples/examples-fsharp/RandomAndDistributions.fsx
rename to examples/examples-fsharp/RandomAndDistributions.fs
index 538cbfb9..1fe936a0 100644
--- a/examples/examples-fsharp/RandomAndDistributions.fsx
+++ b/examples/examples-fsharp/RandomAndDistributions.fs
@@ -15,22 +15,9 @@ distribution, like a Gaussian or Poisson. You can do that with one of our probab
distribution classes, or in F# also using the `Sample` module. Once parametrized,
the distribution classes also provide a variety of other functionality around probability
distributions, like evaluating statistical distribution properties or functions.
-
-Initialization
---------------
-
-We need to reference Math.NET Numerics and open the namespaces for
-random numbers and probability distributions:
-
- using MathNet.Numerics.Random;
- using MathNet.Numerics.Distributions;
-
-Or in F#:
*)
-// Only needed in scripts/interactive
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
+module RandomAndDistributions
open MathNet.Numerics.Random
open MathNet.Numerics.Distributions
@@ -115,7 +102,7 @@ boolean argument at creation or by setting `Control.ThreadSafeRandomNumberGenera
let a = Random.system ()
let b = Random.systemSeed (RandomSeed.Guid())
-let c = Random.crypto ()
+//let c = Random.crypto ()
let d = Random.mersenneTwister ()
let e = Random.mersenneTwisterWith 1000 true (* thread-safe *)
let f = Random.xorshift ()
@@ -146,7 +133,7 @@ as last argument. A few more examples, this time in F#:
// some probability distributions
let normal = Normal.WithMeanVariance(3.0, 1.5, g)
let exponential = Exponential(2.4)
-let gamma = Gamma(2.0, 1.5, Random.crypto())
+//let gamma = Gamma(2.0, 1.5, Random.crypto())
let cauchy = Cauchy(0.0, 1.0, Random.mrg32k3aWith 10 false)
let poisson = Poisson(3.0)
let geometric = Geometric(0.8, Random.system())
@@ -154,8 +141,8 @@ let geometric = Geometric(0.8, Random.system())
// sample some random rumbers from these distributions
let continuous =
[ yield normal.Sample()
- yield exponential.Sample()
- yield! gamma.Samples() |> Seq.take 10 ]
+ yield exponential.Sample() ]
+// yield! gamma.Samples() |> Seq.take 10 ]
let discrete =
[ poisson.Sample()
@@ -165,7 +152,7 @@ let discrete =
// direct sampling (without creating a distribution object)
let u = Normal.Sample(Random.system(), 2.0, 4.0)
let v = Laplace.Samples(Random.mersenneTwister(), 1.0, 3.0) |> Seq.take 100 |> List.ofSeq
-let w = Rayleigh.Sample(c, 1.5)
+//let w = Rayleigh.Sample(c, 1.5)
let x = Hypergeometric.Sample(h, 100, 20, 5)
(**
@@ -180,13 +167,13 @@ some of them are also available with the `Ln`-suffix.
*)
// distribution properties of the gamma we've configured above
-let gammaStats =
- ( gamma.Mean,
- gamma.Variance,
- gamma.StdDev,
- gamma.Entropy,
- gamma.Skewness,
- gamma.Mode )
+//let gammaStats =
+// ( gamma.Mean,
+// gamma.Variance,
+// gamma.StdDev,
+// gamma.Entropy,
+// gamma.Skewness,
+// gamma.Mode )
// probability distribution functions of the normal we've configured above.
let nd = normal.Density(4.0) (* pdf *)
@@ -220,8 +207,8 @@ or in C#:
Let's do some random walks, using distributions and random sources defined above (TODO: Graph):
*)
-Seq.scan (+) 0.0 (normal.Samples()) |> Seq.take 10 |> Seq.toArray
-Seq.scan (+) 0.0 (Sample.normalSeq 0.0 0.5 a) |> Seq.take 10 |> Seq.toArray
+let a1 = Seq.scan (+) 0.0 (normal.Samples()) |> Seq.take 10 |> Seq.toArray
+let a2 = Seq.scan (+) 0.0 (Sample.normalSeq 0.0 0.5 a) |> Seq.take 10 |> Seq.toArray
(**
Composing Distributions
@@ -247,7 +234,7 @@ let s2f rng = Sample.map2 (*) (Sample.normal 2.0 1.5) (Sample.cauchy 2.0 0.5) rn
let s2s rng = Sample.mapSeq2 (*) (Sample.normalSeq 2.0 1.5) (Sample.cauchySeq 2.0 0.5) rng
// Taking some samples from the composed function
-Seq.take 10 (s2s (Random.system())) |> Seq.toArray
+let a3 = Seq.take 10 (s2s (Random.system())) |> Seq.toArray
// The random walk from above, but this time using the composition from above
-Seq.scan (+) 0.0 (s1s a) |> Seq.take 10 |> Seq.toArray
+let a4 = Seq.scan (+) 0.0 (s1s a) |> Seq.take 10 |> Seq.toArray
diff --git a/examples/examples-fsharp/Vectors.fsx b/examples/examples-fsharp/Vectors.fs
similarity index 58%
rename from examples/examples-fsharp/Vectors.fsx
rename to examples/examples-fsharp/Vectors.fs
index 5e6692d0..9be40910 100644
--- a/examples/examples-fsharp/Vectors.fsx
+++ b/examples/examples-fsharp/Vectors.fs
@@ -1,35 +1,4 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2013 Math.NET
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-#r "../../out/lib/Net40/MathNet.Numerics.dll"
-#r "../../out/lib/Net40/MathNet.Numerics.FSharp.dll"
+module Vectors
open MathNet.Numerics.LinearAlgebra
open MathNet.Numerics.LinearAlgebra.Double
diff --git a/examples/examples-fsharp/examples-fsharp.fsproj b/examples/examples-fsharp/examples-fsharp.fsproj
index f8e7c0bb..9f91081d 100644
--- a/examples/examples-fsharp/examples-fsharp.fsproj
+++ b/examples/examples-fsharp/examples-fsharp.fsproj
@@ -1,4 +1,5 @@
+
net45;net46;netstandard1.6;netstandard2.0
false
@@ -7,17 +8,23 @@
false
-
- NETSTANDARD;NOSYSNUMERICS
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+