src.pydasa.analysis.simulation#
Module for Monte Carlo Simulation execution and analysis in PyDASA.
This module provides the MonteCarlo class for performing Monte Carlo simulations on dimensionless coefficients derived from dimensional analysis.
Classes:
MonteCarlo: Performs Monte Carlo simulations on dimensionless coefficients.
IMPORTANT: Based on the theory from:
# H.Gorter, Dimensionalanalyse: Eine Theoririe der physikalischen Dimensionen mit Anwendungen
Classes#
MonteCarlo class for stochastic analysis in PyDASA. |
Module Contents#
- class src.pydasa.analysis.simulation.MonteCarlo#
Bases:
pydasa.core.basic.Foundation,pydasa.elements.specs.numerical.BoundsSpecsMonteCarlo class for stochastic analysis in PyDASA.
Performs Monte Carlo simulations on dimensionless coefficients to analyze the coefficient’s distribution and sensitivity to input parameter variations.
- Parameters:
Foundation – Foundation class for validation of symbols and frameworks.
BoundsSpecs – Value bounds for statistical properties (mean, median, dev, min, max).
- # Core Identification
- # Coefficient and Expression Management
- _coefficient#
Coefficient for the simulation.
- Type:
Optional[Coefficient]
- _sym_func#
Sympy function of the simulation.
- Type:
Callable
- _exe_func#
Executable function for numerical evaluation.
- Type:
Callable
- # Variable Management
- # Simulation Configuration
- # Results and Input data
- _results#
Raw simulation results.
- Type:
Optional[np.ndarray]
- # Statistics (inherited from BoundsSpecs
_mean, _median, _dev, _min, _max)
- __post_init__()#
__post_init__() Initializes the Monte Carlo simulation.
- Return type:
None
- set_coefficient(coef)#
set_coefficient() Configure analysis from a coefficient.
- Parameters:
coef (Coefficient) – Dimensionless coefficient to analyze.
- Raises:
ValueError – If the coefficient doesn’t have a valid expression.
- Return type:
None
- run(iters=None, mode=SimulationMode.DIST.value)#
run() Execute the Monte Carlo simulation.
- Parameters:
- Raises:
ValueError – If simulation is not ready or encounters errors during execution.
- Return type:
None
- get_confidence_interval(conf=0.95)#
get_confidence_interval() Calculate the confidence interval.
- Parameters:
conf (float, optional) – Confidence level for the interval. Defaults to 0.95.
- Raises:
ValueError – If no results are available or if the confidence level is invalid.
- Returns:
Lower and upper bounds of the confidence interval.
- Return type:
- extract_results()#
extract_results() Extract simulation results.
- Returns:
Dictionary containing simulation results.
- Return type:
Dict[str, NDArray[np.float64]]
- property variables: Dict[str, pydasa.elements.parameter.Variable]#
variables Get the variables involved in the simulation.
- property coefficient: pydasa.dimensional.buckingham.Coefficient | None#
coefficient Get the coefficient associated with the simulation.
- Returns:
The associated Coefficient object, or None.
- Return type:
Optional[Coefficient]
- property results: numpy.typing.NDArray[numpy.float64]#
results Raw simulation results.
- Returns:
Copy of the simulation results.
- Return type:
NDArray[np.float64]
- Raises:
ValueError – If no results are available.
- property data: Dict[str, numpy.typing.NDArray[numpy.float64]]#
data Get the input data dictionary.
- Returns:
Copy of input data mapping variable names to arrays.
- Return type:
Dict[str, NDArray[np.float64]]
- Raises:
ValueError – If no data is available.
- property statistics: Dict[str, float | int | None]#
statistics Get the statistical analysis of simulation results.
- Raises:
ValueError – If no results are available.
- Returns:
Dictionary containing statistical properties.
- Return type:
- property experiments: int#
experiments Number of simulation experiments.
- Returns:
Current number of experiments.
- Return type:
- property cat: str#
mode Get simulation execution category.
- Returns:
Current simulation category (DIST or DATA).
- Return type:
- property count: int#
count Number of valid simulation results.
- Returns:
Result count.
- Return type:
- Raises:
ValueError – If no results are available.
- property summary: Dict[str, float | int | None]#
summary Get the statistical analysis of simulation results.
- clear()#
clear() Reset all attributes to default values.
- Return type:
None