NProbability
A numeric-only — handles any condition compute-engine can evaluate at a point, not just the shapes Probability recognizes symbolically.
NProbability(cond, Distributed(x, dist))tries the exact Probability first; otherwise sums (discrete) or integrates (continuous) the indicator of cond against the PDF numerically. Always returns a machine float.Typed signatures
| Type | Package | Applies |
|---|---|---|
(any, expression<Distributed>) -> number | statistics | always |
Details
- Tries
Probability(cond, Distributed(x, dist))first, converted to a float, whenever it resolves. - Otherwise sums/integrates
PDF(x)over exactly the points/region wherecondholds — evaluated by direct numeric substitution, socondcan be any boolean expression compute-engine can evaluate at a concrete point (Mod,Or,x^2 > 1, ...), not onlyEqual/Less/LessEqual/And. - Continuous conditions are NOT generally smooth indicators (
x^2 > 1jumps at ) — plain tanh-sinh quadrature loses most of its accuracy right at a jump, so the boundary is located first (by bisection) and each constant-truth piece is integrated on its own. - Same tail/convergence tolerance as NExpectation; same scope gap for wave-4 compound distributions.
Examples
Basic #
for standard normal — Probability itself stays unevaluated (x^2 > 1 isn't Equal/Less/LessEqual/And), and the indicator has two jumps (), split off before integrating. Cross-checked against wolframscript's N[NProbability[x^2 > 1, x \[Distributed] NormalDistribution[0,1]], 10].
Scope #
for — an infinite discrete sum, condition on Mod. Cross-checked against wolframscript's N[NProbability[Mod[x,2] == 0, x \[Distributed] PoissonDistribution[4]], 10].
Agrees with Probability's own exact CDF-based answer for the same condition (N[92/(5 e^3)]) — the exact path is tried first and used whenever it resolves.
About
| Examples | 4 |
|---|---|
| Checked against | Wolfram Language 1 agree |
See also: Probability, NExpectation, Distributed