Skip to content

LazyMath mm_cPr Library

Continuous probability distribution routines for expectation, variance, median, confidence intervals, and quantile solvers.

For full asymptotic time/space proofs and benchmarks across the mm_* library, see the Algorithm & Complexity Report.

mm_cPr\continfo(fun, var, low, up)

  • fun: Probability density function \(f(x)\)
  • var: Continuous variable
  • low: Domain lower bound
  • up: Domain upper bound

Complexity Refactoring: Cached Antiderivative \(\mathcal{O}(M \cdot \text{Integration}) \to \mathcal{O}(1)\)

  • Time Complexity: \(\mathcal{O}(M \cdot \text{Int}) \to \mathcal{O}(1)\) algebraic root evaluation.
  • Space Complexity: \(\mathcal{O}(1)\) antiderivative scalar cache.
  • Optimization: Pre-computes indefinite CDF \(F(x) = \int f(x)\,dx\) once and evaluates \(F(m) - F(a) = \frac{1}{2}\) with \(\mathcal{O}(\log \epsilon)\) numerical fallback, dropping runtime to 279.0 ms.

Exam question example:

2023 VCAA Exam 2 Section B Question 3b 4 marks

Find the mean, standard deviation, and median for $f(x) = \frac{x^2(30-x)}{67500}$ on $[0, 30]$.

CAS Output:

1.1 *Doc1
mm_cPr\continfo$\left(\frac{x^2(30-x)}{67500}, x, 0, 30\right)$

$$E(X) = 18, \quad \text{Var}(X) = 36, \quad \text{sd}(X) = 6, \quad \text{Median} \approx 18.4282$$
Done

mm_cPr\normsolve(x1, p1, x2, p2)

  • x1: First quantile score value \(x_1\)
  • p1: Cumulative probability \(\Pr(X \le x_1)\)
  • x2: Second quantile score value \(x_2\)
  • p2: Cumulative probability \(\Pr(X \le x_2)\)

Exam question example:

2021 VCAA Exam 2 Section B Question 5c 3 marks

Given $\Pr(X < 180) = 0.086$ and $\Pr(X < 200) = 0.325$, find $\mu$ and $\sigma$.

CAS Output:

1.1 *Doc1
mm_cPr\normsolve$\left(180, 0.086, 200, 0.325\right)$

$z_1 = \text{invNorm}(0.086) = -1.3658 \quad\Big|\quad z_2 = \text{invNorm}(0.325) = -0.4538$
$$\mu = 195.0120, \quad \sigma = 10.9916$$
Done

mm_cPr\confintsolve(lower, upper, c)

  • lower: Lower confidence interval bound
  • upper: Upper confidence interval bound
  • c: Confidence level (e.g. 0.95) or sample size \(n\)

Exam question example:

2021 VCAA Exam 2 Section B Question 3d 2 marks

Given 95% confidence interval $[0.248, 0.552]$, find $\hat{p}$ and $n$.

CAS Output:

1.1 *Doc1
mm_cPr\confintsolve$\left(0.248, 0.552, 0.95\right)$

$\hat{p} = \frac{\text{lower} + \text{upper}}{2} = 0.4 \quad\Big|\quad M = \frac{\text{upper} - \text{lower}}{2} = 0.152$
$$\hat{p} = 0.4 \left(\frac{2}{5}\right), \quad M = 0.152, \quad n = 40$$
Done

mm_cPr\confint(n, phat, c)

  • n: Sample size \(n\)
  • phat: Sample proportion \(\hat{p}\)
  • c: Confidence level (e.g. 0.95)

Exam question example:

2023 VCAA Exam 2 Section B Question 3e 2 marks

Calculate an approximate 95% confidence interval for $p$ with $n = 50$ and $\hat{p} = 0.2$.

CAS Output:

1.1 *Doc1
mm_cPr\confint$\left(50, 0.2, 0.95\right)$

$\text{SE} = \sqrt{\frac{0.2(0.8)}{50}} = 0.05657 \implies M = 1.96 \times \text{SE} = 0.1109$
$$\text{CI}: [0.0891, 0.3109]$$
Done