Skip to content

Probability & Statistics UDFs (methods_udfs / m)

High-performance statistical functions for continuous PDFs, confidence intervals, sample sizes, and normal quantiles.

methods_udfs\binom_min_n(k, p, target)

  • k: Success threshold integer in \(\Pr(X \ge k)\)
  • p: Success probability per trial \(p \in (0, 1)\)
  • target: Target cumulative probability threshold (e.g. \(0.95\) or \(95\))

Exam question example:

2024 VCAA NHT Exam 2 Section B Question 3d 2 marks

A botanist inspects sampled fruit trees. The probability that an inspected tree has fruit fly is $p = 0.08$.

Find the minimum number of trees that must be inspected so that the probability of finding at least one tree with fruit fly is greater than 0.95.

CAS Output:

1.1 *Doc1
m\binom_min_n$\left(1, 0.08, 0.95\right)$

$\text{M1: } \Pr(X \ge 1) \ge \frac{19}{20}, \quad p = \frac{2}{25}, \quad \text{Min } n = 36$
$$\begin{bmatrix} n & \Pr(X < k) & \Pr(X \ge k) \\ 35 & 0.0547 & 0.9453 \\ 36 & 0.0503 & 0.9497 \end{bmatrix}$$
Done

methods_udfs\conf_interval(p1, p2, c, mode)

  • p1: Sample proportion \(\hat{p}\) or lower boundary of confidence interval
  • p2: Sample size \(n\) or upper boundary of confidence interval
  • c: Confidence level (e.g. \(0.95\) or \(95\))
  • mode: Optional mode: "ci" to calculate CI, "n" to calculate required sample size

Exam question example:

2021 VCAA Exam 2 Section B Question 3d 2 marks

An approximate 95% confidence interval for the proportion of students who commute by bicycle is calculated as $[0.248, 0.552]$.

Find the sample proportion $\hat{p}$ and the sample size $n$ used to compute this interval.

CAS Output:

1.1 *Doc1
m\conf_interval$\left(0.248, 0.552, 0.95, \text{""}\right)$

$$\begin{bmatrix} \text{Par} & \text{Value} & \text{4dp} \\ \hat{p} & \frac{2}{5} & 0.4000 \\ \text{ME} & \frac{19}{125} & 0.1520 \\ z & 1.9600 & 1.9600 \\ n & 40 & 40.0000 \end{bmatrix}$$
Done

methods_udfs\cont_pdf_stats(f, x, a, b)

  • f: Probability density function expression \(f(x)\)
  • x: Continuous random variable
  • a: Support domain lower bound
  • b: Support domain upper bound

Exam question example:

2023 VCAA Exam 2 Section B Question 3b 4 marks

The continuous random variable $X$ has probability density function:

\[ f(x) = \begin{cases} \frac{x^2(30-x)}{67500}, & 0 \le x \le 30 \\ 0, & \text{otherwise} \end{cases} \]

Find the mean $E(X)$, standard deviation $\text{sd}(X)$, and median $m$ of $X$.

CAS Output:

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

$\text{M1: } E(X) = \int_0^{30} x\cdot f(x)\,dx = 18$
$\text{M1: } \text{Var}(X) = \int_0^{30} x^2\cdot f(x)\,dx - (18)^2 = 36$
$$\begin{bmatrix} & \text{Exact} & \text{4dp} \\ \text{Area} & 1 & 1.0000 \\ E(X) & 18 & 18.0000 \\ E(X^2) & 360 & 360.0000 \\ \text{Var}(X) & 36 & 36.0000 \\ \text{sd}(X) & 6 & 6.0000 \\ \text{Med } m & \frac{92141}{5000} & 18.4282 \end{bmatrix}$$
Done

methods_udfs\normal_2quant(x1, p1, x2, p2)

  • x1: First quantile score value \(x_1\)
  • p1: Cumulative probability \(\Pr(X \le x_1)\) (as probability or percentage)
  • 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

The mass $X$ of avocados packed into boxes is normally distributed with mean $\mu$ and standard deviation $\sigma$.

Given that $\Pr(X < 180) = 0.086$ and $\Pr(X < 200) = 0.325$, find the values of $\mu$ and $\sigma$, correct to one decimal place.

CAS Output:

1.1 *Doc1
m\normal_2quant$\left(180, 0.086, 200, 0.325\right)$

$\text{M1: } \frac{180 - \mu}{\sigma} = -1.3658$
$\text{M1: } \frac{200 - \mu}{\sigma} = -0.4538$
$$\begin{bmatrix} \text{Par} & \text{Full} & \text{4dp} & \text{2dp} \\ z_1 & -1.3658 & -1.3658 & -1.37 \\ z_2 & -0.4538 & -0.4538 & -0.45 \\ \mu & 195.0120 & 195.0120 & 195.01 \\ \sigma & 10.9916 & 10.9916 & 10.99 \end{bmatrix}$$
Done