User defined Random Variables

MathParser.org - mXparser - logo - Tutorial

*** If you found the software useful donation is something you might consider 🙂 ***

If you found the software useful donation is something you might consider :-)

JAVA code

Case 1: Dependent argument as user defined random variable

import org.mariuszgromada.math.mxparser.*;
...
Argument X = new Argument("X", "5*[Uni]+1");
Expression e = new Expression("X", X);
mXparser.consolePrintln("Res. 1: " + e.getExpressionString() + " = " + e.calculate());
mXparser.consolePrintln("Res. 2: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.3.0.0] Res. 1: X = 1.358437202579746
[mXparser-v.3.0.0] Res. 2: X = 4.620121023820833

Case 2: User defined function as user defined random variable - random walk example

import org.mariuszgromada.math.mxparser.*;
...
Function rWalk = new Function("rWalk(n) = sum( i, 1, n, rList(-1,1) )");
Expression e = new Expression("rWalk(20)", rWalk);
mXparser.consolePrintln("Res. 1: " + e.getExpressionString() + " = " + e.calculate());
mXparser.consolePrintln("Res. 2: " + e.getExpressionString() + " = " + e.calculate());
[mXparser-v.3.0.0] Res. 1: rWalk(20) = 4.0
[mXparser-v.3.0.0] Res. 2: rWalk(20) = -6.0

*** If you found the software useful donation is something you might consider 🙂 ***

If you found the software useful donation is something you might consider :-)

Enjoy! 🙂

 

Best regards,

Mariusz Gromada

Download latest release – v.4.1.1 Aeries: bin + doc + src (.zip 13.4 MB)

Download latest release – v.4.1.1 Aeries: bin only (.zip 4.35 MB) – separate binaries for java: 1.5, 1.6, 1.7, 1.8; .NET: 2.0, 3.0, 3.5, 4.0, 4.5, 4.6, 4.7, .NET Core, .NET Standard, .NET PCL, Xamarin.Android, Xamarin.iOS

Source code .zipSource code .tar.gz View on GitHubMathSpace.pl