This is related to mathnet/mathnet-numerics#60
We want to not have Math stuff on FSharpx and instead contribute it to Math.Net
The INumerics interface and matrix classes from PowerPack are also interesting to port over, but that needs more work as there's overlap. I'll suggest something in a couple of days
Bring Complex & BigRational from F# PowerPack, and DistributionMonad …
Thanks a lot!
Some notes (I can help):
System.Numerics and portable builds
Our portable builds do not currently reference System.Numerics because it is not available on some targets (WP8 and .Net 4.0). Instead we replace them on (and only on) portable builds with equivalent types (Complex, but not yet BigInteger). Luckily the situation has been improved somewhat with .Net 4.5 and VS2012: if we decide to change the portable profile to ".Net 4.5, SL5, Windows Store" and drop WP8 support then we can always reference System.Numerics and get rid of our replacement types. I can take care of that. In order to support BigRational, we need to do either that, or hide BigRational in portable builds. Dropping WP8 is not that a big issue, after all support has just been added in the last release (even though I liked supporting it).
We currently use the Complex type from System.Numerics (or our own type replacing it on portable builds, see point above) for double precision, and our own Complex32 type for single precision. See Complex32.cs, Complex64.cs and Trig.cs. So there is some overlap with the complex types from the PowerPack. It seems our type supports all features of the PowerPack one, but the Complex F# module could still be interesting for convenience. What do you think?
The FSharpPortable project would have to be updated as well (files linked directly to normal project). I can take care of that as well.
Looks interesting! If I understand it correctly, this monad actually represents a "random variable" instead of a "distribution". Can you confirm this? If yes, we may want to rename it to avoid confusion (since we do provide all kind of standard probability distributions).
Add N and Z implementation from FSharp.Core to portable build
Wrap the existing Complex type instead of redefining it
Rename Distribution to RandomVariable
Updated the pull request with:
-Include files in portable build
-Include implementation of BigInteger from FSharp.Core in portable build
-Revised the Complex to just add the module and a couple of type extensions
-Renamed the DistributionMonad to RandomVariableMonad
On another note, the FSharp tests are being run as a console application. The ones I've added use NUnit. Are you running the tests in CI? I couldn't find a build script to update it to run the new NUnit tests
Unit Tests: The main unit tests are fully integrated, but not yet the F# ones. We better convert all of them to NUnit as well, then I'll add another build step for them in TeamCity.
I'm converting the unit tests
Convert FSharpUnitTests to NUnit + latest FSUnit
Done. Any more feedback?
PS: I plan to do another pull request with the rest of the stuff form PowerPack, but it will probably be in only a few weeks, and it's probably more suitable for a 3.0 version, while this I think can go well in a minor version
Please use postfix type parameters with .NET capitalization and naming
type 'a RandomVariable
Idiomatic F# code generally only uses prefix arguments for "list", "option", "" and "ref" (if at all).
Please also make sure the types are defined in a namespace, rather than in a module so that the user only opens the namespace, i.e.
type Outcome<'T> = ...
type RandomVariable<'T> = ...
module RandomVariable = ...
I think these types and the module should be in a sub-namespace but @cdrnet can advise.
Do not define public symbolic operators like =<< and >>= in this library, but define named functions instead.
Are the big natural and integer types ever needed? I think not? BigInteger is always available in either System.Numerics or FSharp.Core (if System.Numerics is not present). I think the F# open source build does not yet have a portable library though, so perhaps it is needed for he portable build on Mono, but that should be fixed in the F# open source build.
Humm, I though the portable version for FSharp.Core didn't have the BigInteger, but while checking again it seems it has, only Parse is missing. I'll revise
Make RandomVariable more idiomatic and move it out of the global Math…
Replace full BigInteger implementation with extension to add the Pars…
…e method in Portable version
Looking at https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/math/z.fsi#L44 I think BigInteger.Parse is there, but not the culture-aware version taking three arguments.
Yes, in the source code it appears so, but in the actual dll (Program Files\Reference Assemblies\Microsoft\FSharp\3.0\Runtime.NETPortable\FSharp.Core.dll) it's not.
FYI, I've enabled the F# unit tests in TeamCity, works nicely. Thanks again.