# Probability

## Probability(b, I, w)

Returns an estimate of the probability that the boolean condition «b» is true. This is computed as the fraction of samples for which the condition «b» holds.

When the index «I» is not specified, the probability based on the uncertain chance variables in your model. In this case, the probability is taken over the Run index and «b» is evaluated in sample mode, so it is the probability based on the Monte Carlo sample.

Probability is equivalent to `Mean(b<>False, I, w).`

## Example

`Probability(engine_status = 'overheated') → 0.01`

## Optional parameters

### I

You can apply the function to a historical data set by specifying the index «I», which returns the fraction of data points that satisfy the condition. For example:

`Probability(Historic_fuel_price < Current_fuel_price, Past_years) → 0.25`

### W

The optional «w» parameter enables weighted probability estimates. When «w» parameter is specified, each point is assigned a different weight. The «w» parameter should be indexed by «I», or by Run when the «I» parameter is not specified. The «w» parameter defaults to the system variable SampleWeighting when «I» is Run.

## More details

The Probability function can be a poor option for computing cumulative distribution functions. For example, you might be tempted to computed the cumulative distribution of a standard normal distribution at `z` using

`Probability(Normal(0, 1) <= z)`

Because this is returning the fraction of samples that are less than `z`, the estimate may have a substantial amount of sampling error. In addition, every value of `z` landing between the same two sample points has the same computed probability, which essentially makes the partial derivative at `z` equal to zero for points other than the sample points themselves, thus destroying information that may be needed if you need to solve a non-linear optimization (NLP). A much better option is to use an Analytic cumulative distribution function, such as

`CumNormal(z, 0, 1)`