Skip to content

NProbability ​

A numeric-only P(cond)P(cond) — 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
TypePackageApplies
(any, expression<Distributed>) -> numberstatisticsalways

Domain: Statistics

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 where cond holds — evaluated by direct numeric substitution, so cond can be any boolean expression compute-engine can evaluate at a concrete point (Mod, Or, x^2 > 1, ...), not only Equal/Less/LessEqual/And.
  • Continuous conditions are NOT generally smooth indicators (x^2 > 1 jumps at x=±1x=\pm 1) — 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 10−1210^{-12} tail/convergence tolerance as NExpectation; same scope gap for wave-4 compound distributions.

Examples

Basic #

P(X2>1)=2(1−Φ(1))≈0.3173105079P(X^2 > 1) = 2(1-\Phi(1)) \approx 0.3173105079 for standard normal XX — Probability itself stays unevaluated (x^2 > 1 isn't Equal/Less/LessEqual/And), and the indicator has two jumps (x=±1x=\pm1), split off before integrating. Cross-checked against wolframscript's N[NProbability[x^2 > 1, x \[Distributed] NormalDistribution[0,1]], 10].

live ↗
InNProbability(x2>1,Distributed(x,NormalDistribution⁡(0,1)))\mathrm{NProbability}(x^2\gt1, \mathrm{Distributed}(x, \operatorname{NormalDistribution}(0, 1)))Out0.317 310 507 838 716 90.317\,310\,507\,838\,716\,9
Scope #

P(X even)=(1+e−2μ)/2≈0.5001677313P(X \text{ even}) = (1+e^{-2\mu})/2 \approx 0.5001677313 for X∼Poisson(4)X \sim \mathrm{Poisson}(4) — an infinite discrete sum, condition on Mod. Cross-checked against wolframscript's N[NProbability[Mod[x,2] == 0, x \[Distributed] PoissonDistribution[4]], 10].

live ↗
InNProbability(x mod 2=0,Distributed(x,PoissonDistribution⁡(4)))\mathrm{NProbability}(x\bmod2=0, \mathrm{Distributed}(x, \operatorname{PoissonDistribution}(4)))Out0.500 167 731 313 946 80.500\,167\,731\,313\,946\,8

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.

live ↗
InNProbability(x≤5,Distributed(x,PoissonDistribution⁡(3)))\mathrm{NProbability}(x≤5, \mathrm{Distributed}(x, \operatorname{PoissonDistribution}(3)))Out0.916 082 057 968 696 60.916\,082\,057\,968\,696\,6
Applications #

The rate reduces to 1296/1251296/125, and the probability is a number

live ↗
InNProbability(n≤15,Distributed(n,PoissonDistribution⁡(10 368 000×(10−6))))\mathrm{NProbability}(n≤15, \mathrm{Distributed}(n, \operatorname{PoissonDistribution}(10\,368\,000×(10^{-6}))))Out0.937 281 035 306 783 90.937\,281\,035\,306\,783\,9
About
Examples4
Checked againstWolfram Language 1 agree

See also: Probability, NExpectation, Distributed