LazyMath mm_dPr Library
Discrete probability distribution routines for binomial statistics, minimum trial solver, and interactive binomial sampling.
For full asymptotic time/space proofs and benchmarks across the
mm_*library, see the Algorithm & Complexity Report.
mm_dPr\samplebinom(n, p)
n: Number of independent trials \(n\)p: Success probability per trial \(p\)
Exam question example:
Simulate a binomial experiment with $n = 400$ and $p = 0.4$. When $n > 10$, an on-screen dialog automatically asks whether to render the full discrete table, avoiding CAS slowdown.
CAS Output:
mm_dPr\binominfo(n, p)
n: Number of independent trials \(n\)p: Success probability per trial \(p\)
Exam question example:
Let $X \sim \text{Bi}(20, 0.28)$. Find the mean $E(X)$, variance $\text{Var}(X)$, standard deviation $\text{sd}(X)$, and standard deviation of $\hat{p}$.
CAS Output:
mm_dPr\binomsolve(n, p, thres, mode)
n: Known trials (or parameter string"n")p: Known success probability (or parameter string"p")thres: Probability target thresholdmode: Inequality condition e.g.">="or"<="
Complexity Refactoring: Analytical Logarithmic Jump \(\mathcal{O}(N_{\text{trials}}) \to \mathcal{O}(1)\)
- Time Complexity: \(\mathcal{O}(N_{\text{trials}}) \to \mathcal{O}(1)\) direct logarithmic jump + \(\le 2\) boundary checks.
- Space Complexity: \(\mathcal{O}(N_{\text{trials}}) \to \mathcal{O}(1)\) auxiliary space.
- Optimization: Replaces the sequential
While binomCdf(...) < targetloop with the exact logarithmic lower-bound initialization \(n_0 = \left\lfloor \frac{\ln(1-T)}{\ln(1-p)} \right\rfloor\), executing in 144.8 ms.
Exam question example:
Find the smallest integer $n$ such that $\Pr(X \ge 1) \ge 0.95$ when $p = 0.08$.
CAS Output: