Double MonteCarlo(TRealFunction Fun, Double lb, Double ub, TMtxFloatPrecision FloatPrecision, TVec Constants, Object[] ObjConst, Int32 N)
Numerical integration by Monte Carlo method.
| # | Name | Description |
|---|---|---|
| 1 | Fun | Integrating function. |
| 2 | Constants | Additional constants defining Fun function, usually nil/null. |
| 3 | ObjConst | Additional objects defining Fun function, usually nil/null. |
| 4 | lb | Defines lower bound. |
| 5 | ub | Defines pper bound. |
| 6 | N | Number of random points in [lb,ub] interval (see comments above). |
| 7 | FloatPrecision | Defines the computational precision to be used by the routine. |
Returns: Double - the numerical approximate on integral of function Fun between limits lb and ub.
Remarks:
Performs a numerical integration of function of single variable by using Monte Carlo method.
Examples
private double IntFun(TVec x, TVec c, params object[] o)
{
double x = x[0];
return System.Math.Sin(x);
}
private void Example()
{
TIntStopReason sr;
double area = MtxIntDif.MonteCarlo(IntFun,0.0,System.Math.PI,null,null,65536);
}
See Also: MtxIntDiff.QuadGauss