APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
132 stars 161 forks source link

Adding Accord.Net Statistics package into ApsimX #3673

Closed sno036 closed 5 years ago

sno036 commented 5 years ago

Accord (http://accord-framework.net/) is a whole bunch of useful libraries for many things (don't be fooled by the Machine Learning up front and centre in the website) including the generation of statistical distributions. I would like the ability to generate some bi-variate log-normal distributions in a manager script. @FlorjanCamlek has tested using this in a standalone application getting Accord from https://www.nuget.org/packages/Accord.Statistics/3.8.2-alpha. He has also populated a simple test that might work and is attached. @hol353 would you mind seeing if this is OK/suitable to include with APSIM and adding it to the solution if it is? Thanks, Val

TestAccord.zip

jbrider commented 5 years ago

@sno036 not sure it would be a great idea to include libraries that are no longer being actively supported. There haven't been any changes on the alpha version you referenced since 2017. I have used MathNet.Numerics in another project and it seems to have a pretty good range of statistical methods... though I won't pretend to know if it's better or worse than the Accord libraries. It has however been updated to use the .NETStandard libraries (cross platform compatible) within the last 6 months.

sno036 commented 5 years ago

@FlorjanCamlek what do you think of this. There is a bi-variate normal distribution (https://numerics.mathdotnet.com/Probability.html) it seems but can you see a way of sampling out of a particular space (i.e. drawn from that population but done so selectively so as to have close to a predetermined mean) in that distribution?

FlorjanCamlek commented 5 years ago

@sno036 I haven't found a bivariate normal distribution, but there is a matrix normal distribution, which is apparently a generalisation of the multivariate normal distribution. So in theory it should be possible to do this with the MathNet.Numerics library

sno036 commented 5 years ago

Thanks @FlorjanCamlek - would you like to give this a whirl (inside APSIM X) using this library via nuget (unless @jbrider has already added that into the solution)? If it works then raise a pull request and @hol353 can assess/make a decision.

zur003 commented 5 years ago

If I understand the thread so far, the intent is to be able to use the package in Manager scripts, not in standard Apsim models. What we really need here is a way for manager scripts to be able to reference any .Net assembly. I'd rather not see any more packages being pulled via nuget into the main Apsim distribution than necessary.

FlorjanCamlek commented 5 years ago

@sno036 @zur003 Yes, that's correct. The package (MathNet.Numerics is fine) would be used in a Manager script. Not sure what the best way to enable that is.