ndraws (int) – The number of random draws to perform.
fcns (dict[monaco.mc_enums.SimFunctions, Callable]) – fcns is a dict with keys SimFunctions.PREPROCESS, RUN, and POSTPROCESS.
These point to user-defined functions with certain input and output
structures, please see the documentation on how to construct these
functions.
firstcaseismedian (bool, default: False) – Whether the first case represents the median value.
fcns (dict[monaco.mc_enums.SimFunctions, Callable]) – fcns must be a dict with keys SimFunctions.PREPROCESS, RUN, and
POSTPROCESS, which point to special user-defined functions.
Calculate the sensitivity indices for the specified outvars.
Parameters:
outvarnames (None | str | Iterable[str] (default: None)) – The outvar names to calculate sensitivity indices for. If None,
then calculates sensitivities for all scalar outvars.
tol (float, default 1e-6) – The convergence tolerance for scipy’s minimize function acting on the
negative log likelihood function.
verbose (bool, default False) – Whether to print diagnostic information.
Generate a correlation matrix between all the scalar variables.
Returns:
(corcoeffs, covvarlist) – corrcoeffs is a correlation matrix between all the scalar input
and output variables.
covvarlist is a list of all the scalar input and output variables.
Generate a covariance matrix between all the scalar variables.
Returns:
(covs, covvarlist) – covs is a covariance matrix between all the scalar input and
output variables.
covvarlist is a list of all the scalar input and output variables.
Plot all the scalar variables against each other in a grid.
Parameters:
scalarvars (list[monaco.mc_var.InVar | monaco.mc_var.OutVar | str]) – The variables to plot. If None, then grabs all the input variables
and scalar output variables.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: False) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
fig (matplotlib.figure.Figure, default: None) – The figure handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, axes) – fig is the figure handle for the plot.
axes is a tuple of the axes handles for the plots.
Export the drawn nums for all the invars to file for use externally.
See monaco.Sim.exportVars docstring for csv and json formatting.
Parameters:
filename (Optional[str | pathlib.Path]) – The file to save to. Must be a csv or json.
If a str, then will save in the resultsdir.
If None, then will save to ‘{self.name}_invarnums.json’.
Export the nums for all the outvars to file for use externally.
See monaco.Sim.exportVars docstring for csv and json formatting.
Parameters:
filename (Optional[str | pathlib.Path]) – The file to save to. Must be a csv or json.
If a str, then will save in the resultsdir.
If None, then will save to ‘{self.name}_outvarnums.json’.
Import draws from an external file as InVals. For each of the keyword
arguments, they must be the same length as the number of invars.
See monaco.Sim.importVars docstring for csv and json formatting.
Parameters:
filepath (str | pathlib.Path) – The file to load from. Must be a csv or json.
dists (list[rv_discrete | rv_continuous], default: None) – A list of the distribution that was used for the draws. Needed if
it is desired to plot the analytical distribution or run a DVARS
sensitivity analysis. Note that for discrete distributions, the
calcuated percentiles will not likely match the original draws.
distskwargs (list[dict[str, Any]], default: None) – A list of the distribution kwargs that were used for the draws.
Must be matched with dists above.
nummaps (list[dict[Any, float]], default: None) – A list of nummap dicts mapping numbers to nonnumeric values.
Import results from an external file as OutVals, convert to OutVars.
See monaco.Sim.importVars docstring for csv and json formatting.
Parameters:
filepath (str | pathlib.Path) – The file to load from. Must be a csv or json.
nummaps (list[dict[float, Any]], default: None) – A list of nummap dicts mapping numbers to nonnumeric values. Note
that this is reversed from providing valmaps to OutVals.
Object to hold all the data for a single Monte Carlo case.
Parameters:
ncase (int) – The number of this case.
ismedian (bool) – Whether this represents the median case.
invars (dict[str, monaco.mc_var.InVar]) – A dict pointing to all of the input variables.
constvals (dict[str, Any], default: None) – A dict of any constant values common to all cases.
keepsiminput (bool, default: True) – Whether to keep the siminput after running.
keepsimrawoutput (bool, default: True) – Whether to keep the simrawoutput after postprocessing.
seed (int, default: np.random.get_state(legacy=False)['state']['key'][0]) – The random seed to pass to the run function for this case. Not used in
as part of any Monte Carlo sampling.
stat (monaco.mc_enums.VarStatType | Callable) – The statistic to generate. Can be custom. If custom, must be able to
accept an “axis” kwarg for bootstrap vectorization.
statkwargs (dict[str:Any]) – The keyword arguments for the variable statistic.
bootstrap (bool (default: True)) – Whether to use bootstrapping to generate confidence intervals for the
statistic.
bootstrap_k (int (default: 10)) – The k’th order statistic to determine the number of bootstrap draws for
the given confidence level. Must be >= 1. Set higher for a smoother
bootstrap distribution.
conf (float (default: 0.95)) – The confidence level for the confidence interval.
seed (int (default: np.random.get_state(legacy=False)['state']['key'][0])) – The random seed to use for bootstrapping.
A wrapper function to allow using a bootstrap function that uses kwargs.
Relies on self.fcn and self.fcnkwargs already being set. Note that fcn
must accept an axis kwarg if bootstrapping.
Parameters:
x (Any) – The input for the function.
axis (int (default: None)) – The axis of x to calculate along.
The preprocess function must take in only a moncao.mc_case.Case object. It
then must return a tuple of the input arguments for the run function.
The run function will take in whatever inputs and return whatever outputs.
It it recommended to package the outputs into a tuple.
The postprocess function must take in as its first argument a
moncao.mc_case.Case object, followed by the outputs from the run function.
The simulation will attempt to unpack the run function outputs if they are
stored in a tuple.
For nummap and valmap, we need to use values as keys in a dictionary.
This function will return the string representation of a value if that
value is not hashable.
Parameters:
val (Any) – The value to hash.
Returns:
hashable_val – A hashable representation of the val.
ninvar (int) – For all but the ‘random’ method, must define which number input
variable is being sampled, ninvar >= 1. The ‘sobol’ and
‘sobol_random’ methods must have ninvar <= 21201
ninvar_max (int) – The total number of invars, ninvar_max >= ninvar. Used for caching.
seed (int, default: np.random.get_state(legacy=False)['state']['key'][0]) – The random seed. Not used in ‘sobol’ or ‘halton’ methods.
Returns:
pcts – The random samples. Each sample is 0 <= pct <= 1.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: True) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
cumulative (bool, default: False) – Whether to plot the histograms as cumulative distribution functions.
orientation (monaco.mc_enums.PlotOrientation, default: 'vertical') – The orientation of the histogram. Either ‘vertical’ or ‘horizontal’.
rug_plot (bool, default: True) – Whether to plot rug marks.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
orientation (monaco.mc_enums.PlotOrientation, default: 'vertical') – The orientation of the histogram. Either ‘vertical’ or ‘horizontal’.
rug_plot (bool, default: True) – Whether to plot rug marks.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are highlighted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: True) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are highlighted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are highlighted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are highlighted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are highlighted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
For a Monte Carlo integration where the reference value is known, plot the
running integration error along with error bounds for a given confidence
level.
Parameters:
outvar (monaco.mc_var.OutVar) – The variable representing the integration estimate.
dimension (int) – The number of dimensions over which the integration was performed.
volume (float) – The total integration volume.
refval (float) – The reference value for the integration.
conf (float, default: 0.95) – The confidence level for the error estimate. 0.95 corresponds to 95%.
samplemethod (monaco.mc_enums.SampleMethod) – The sample method used for integration. Either ‘random’ or ‘sobol’.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
For a Monte Carlo integration where the reference value is known, plot the
running integration error along with error bounds for a given confidence
level.
Parameters:
outvar (monaco.mc_var.OutVar) – The variable representing the integration estimate.
sensitivities (monaco.mc_enums.Sensitivities, default: 'ratios') – The sensitivities to plot. Either ‘ratios’ or ‘indices’.
sort (bool, default: True) – Whether to show the sensitivity indices sorted from greatest to least.
ax (matplotlib.axes.Axes, default: None) – The axes handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, ax) – fig is the figure handle for the plot.
ax is the axes handle for the plot.
Parse the invarspace input for plotting functions. If already an iterable
of the right length, passes through. If a single value, returns a list of
the invarspace of the right length.
Parameters:
invar_space (monaco.InVarSpace | Iterable[InVarSpace]) – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
nvars (int) – The length of the list to generate.
Returns:
invar_space_list – A list of length nvars for the desired InVarSpace’s.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: False) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
fig (matplotlib.figure.Figure, default: None) – The figure handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, axes) – fig is the figure handle for the plot.
axes is a tuple of the axes handles for the plots.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: False) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
cumulative (bool, default: False) – Whether to plot the histograms as cumulative distribution functions.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
fig (matplotlib.figure.Figure, default: None) – The figure handle to plot in. If None, a new figure is created.
(matplotlib.axes.Axes, matplotlib.axes.Axes, matplotlib.axes.Axes)) – fig is the figure handle for the plot.
(ax1, ax2, ax3) are the axes handles for the central, y-axis, and
x-axis plots, respectively.
Plot multiple variables against each other in a triangular grid. The
off-diagonal grid locations show scatterplots of the two corresponding
variables. The plots along the diagonal show histograms for the
corresponding variables.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: False) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
cumulative (bool, default: False) – Whether to plot the histograms as cumulative distribution functions.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
fig (matplotlib.figure.Figure, default: None) – The figure handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, axes) – fig is the figure handle for the plot.
axes is a tuple of the axes handles for the plots, starting from
the top-left corner and working left-to-right, then top-to-bottom.
Plot multiple variables against each other in a rectangual grid. The
left column and bottom row show histograms for each variable, and the middle
grid locations show the scatter plots between each pari of variables.
cases (None | int | Iterable[int], default: None) – The cases to plot. If None, then all cases are plotted.
highlight_cases (None | int | Iterable[int], default: []) – The cases to highlight. If [], then no cases are highlighted.
rug_plot (bool, default: False) – Whether to plot rug marks.
cov_plot (bool, default: False) – Whether to plot a covariance ellipse at a certain gaussian percentile
level.
cov_p (None | float | Iterable[float], default: None) – The gaussian percentiles for the covariance plot.
cumulative (bool, default: False) – Whether to plot the histograms as cumulative distribution functions.
invar_space (monaco.InVarSpace | Iterable[InVarSpace], default: 'nums') – The space to plot invars in, either ‘nums’ or ‘pcts’. If an iterable,
specifies this individually for each of varx, vary, and varz.
fig (matplotlib.figure.Figure, default: None) – The figure handle to plot in. If None, a new figure is created.
title (str, default: '') – The figure title.
Returns:
(fig, axes) – fig is the figure handle for the plot.
axes is a tuple of the axes handles for the plots, starting from
the top-left corner and working left-to-right, then top-to-bottom.
Converts a percentile to a gaussian sigma value (1-sided), or to the
sigma value for which the range (-sigma, +sigma) bounds that percent of
the normal distribution (2-sided).
Converts a percentile to a sigma value which bounds a df-dimensional
gaussian distribution, used in generating confidence ellipsoids. Note
that in the 1-D case, np.sqrt(scipy.stats.chi2.ppf(p, df=1)) is
equivalent to pct2sig(p >= 0.5, bound = ‘2-sided’) ==
scipy.stats.norm.ppf(1-(1-p)/2)
Parameters:
p (float) – The percentile to convert, 0 < p < 1.
df (int) – The degrees of freedom, df > 0.
Returns:
sig – The gaussian sigma value for the input percentile.
Converts a sigma value which bounds a df-dimensional gaussian distribution,
to a percentil used in generating confidence ellipsoids. Note that in the
1-D case, scipy.stats.chi2.cdf(sig**2, df=1) is equivalent to
sig2pct(sig > 0, bound=’2-sided) == 1-(1-scipy.stats.norm.cdf(sig))*2
Parameters:
sig (float) – The gaussian sigma value to convert, sig > 0.
For an Order Statistic Tolerance Interval, find the minimum n from k, p,
and c
Notes
This function returns the number of cases n necessary to say that the true
result of a measurement x will be bounded by the k’th order statistic with
a probability p and confidence c. Variables l and u below indicate lower
and upper indices of the order statistic.
For example, if I want to use my 2nd highest measurement as a bound on 99%
of all future samples with 90% confidence:
The 388th value of x when sorted from low to high, or sorted(x)[-2], will
bound the upper end of the measurement with P99/90.
‘2-sided’ gives the result for the measurement lying between the k’th lowest
and k’th highest measurements. If we run the above function with
bound=’2-sided’, then n = 668, and we can say that the true measurement lies
between sorted(x)[1] and sorted(x)[-2] with P99/90.
See chapter 5 of Reference [1] for statistical background.
Parameters:
k (int) – The k’th order statistic.
p (float (0 < p < 1)) – The percent covered by the tolerance interval.
c (float (0 < c < 1)) – The confidence of the interval bound.
nmax (int, default: 1e7) – The maximum number of draws. Hard limit of 2**1000.
bound (monaco.mc_enums.StatBound, default: '2-sided') – The statistical bound, either ‘1-sided’ or ‘2-sided’.
Returns:
n – The number of samples necessary to meet the constraints.
Order Statistic Percentile, find minimum n from k, P, and c.
Notes
This function returns the number of cases n necessary to say that the true
Pth percentile located at or between indices iPl and iPu of a measurement x
will be bounded by the k’th order statistic with confidence c.
For example, if I want to use my 5th nearest measurement as a bound on the
50th Percentile with 90% confidence:
The 19-5 = 14th and 20+5= 25th values of x when sorted from low to high, or
[sorted(x)[13], sorted(x)[24]] will bound the 50th percentile with 90%
confidence.
‘2-sided’ gives the upper and lower bounds. ‘1-sided lower’ and
‘1-sided upper’ give the respective lower or upper bound of the Pth
percentile over the entire rest of the distribution.
See chapter 5 of Reference [2] for statistical background.
Parameters:
k (int) – The k’th order statistic.
P (float (0 < P < 1)) – The target percentile.
c (float (0 < c < 1)) – The confidence of the interval bound.
nmax (int, default: 1e7) – The maximum number of draws. Hard limit of 2**1000.
bound (monaco.mc_enums.StatBound, default: '2-sided') – The statistical bound, ‘1-sided upper’, ‘1-sided lower’, or ‘2-sided’.
Returns:
n – The number of samples necessary to meet the constraints.
Returns the bounding integration error for an input array of numbers. This
error can be a float point estimate if runningerror == False, or a numpy
array showing running error over the samples, to demonstrate convergence.
If volume == 1, the error returned is a percent error. Otherwise, the error
is absolute over the integration volume.
Parameters:
nums (list[float]) – A list of the integration point estimates across the volume.
dimension (int) – The number of dimensions in the integration volume, dimension > 0.
volume (float) – The integration volume, > 0. If volume == 1 (default), then the error
returned is a percentage of the true integration volume.
conf (float) – Confidence level of the calculated error. This must be 0 < conf < 1,
and should be 0.5 < conf < 1.
samplemethod (monaco.mc_enums.SampleMethod) – Monte Carlo sample method. Either ‘random’ (default and bounding), or
‘sobol’. If using a different sample method, use ‘random’ here.
runningerror (bool) – If False, returns a point estimate. If True, returns an array
containing the running error over all of the integration estimates.
Returns:
error – Either a point estimate of the error if runningerror == False, or an
array of the running error if runningerror is True.
Returns the bounding integration error for an input array of numbers. This
error can be a float point estimate if runningerror == False, or a numpy
array showing running error over the samples, to demonstrate convergence.
If volume == 1, the error returned is a percent error. Otherwise, the error
is absolute over the integration volume.
We generally do not know a-priori what the standard deviation will be, so
best practice is to set to the max range of values on the interval, and
then calculate a better stdev on a lower number of cases, which can then
be subsituted in here to bootleg a more efficient computation.
For sobol sampling, remember to round n to the next power of 2 for balance.
monaco.helper_functions.next_power_of_2(n) can help with this.
Parameters:
error (float) – The target error.
dimension (int) – The number of dimensions in the integration volume, dimension > 0.
volume (float) – The integration volume, > 0. If volume == 1 (default), then the target
error is a percentage of the true integration volume.
stdev (float) – The standard deviation of the integration estimates, stdev > 0. We
generally do not know this a-priori, so use
monaco.integration_statistics.max_stdev to calculate this in that
instance. Or, do a limited number of cases to estimate this before
performing the full run.
conf (float) – Confidence level of the calculated error. This must be 0 < conf < 1,
and should be 0.5 < conf < 1.
samplemethod (monaco.mc_enums.SampleMethod) – Monte Carlo sample method. Either ‘random’ (default and bounding), or
‘sobol’. If using a different sample method, use ‘random’ here.
Returns:
n – The number of sample points required to meet the target integration
error.