Course Test · School: high school

High-school statistics (AP Statistics): RatMath answers

The same twenty exercises, answered with RatMath Core and the Shelf libraries only. The code below was run when this page was built; its output is shown as printed, and compared with the independent answer.

Agrees 20

Libraries used here: core, stats. In this code each library is in scope under its own name (linalg.det, stats.tTest), and Core's names (R, Rational, …) are in scope directly.

  1. 1.Mean and standard deviationAgrees
    For the data 2, 4, 4, 4, 5, 5, 7, 9 find the mean, the sample standard deviation and the population standard deviation.
    Independent answer
    Mean 5; squared deviations sum to 32; s=32/7≈2.138s = \sqrt{32/7} \approx 2.138; σ=32/8=2\sigma = \sqrt{32/8} = 2.
    RatMath code
    const d = [2, 4, 4, 4, 5, 5, 7, 9];
    [stats.mean(d), stats.variance(d), stats.sd(d), stats.sd(d, { population: true })]
    Output
    [5, 32/7, 2.1380899352993950774[7:8], 2]
  2. 2.z-scoresAgrees
    A test has mean 72 and standard deviation 8. What is the z-score of a mark of 86?
    Independent answer
    (86−72)/8=1.75(86 - 72)/8 = 1.75.
    RatMath code
    R`(86 - 72)/8`
    Output
    7/4
  3. 3.Normal probabilityAgrees
    Find P(Z<1.75)P(Z < 1.75) for a standard normal ZZ, to four decimals.
    Independent answer
    0.9599 (table: 0.95994).
    RatMath code
    stats.normal().cdf(R`7/4`)
    Output
    0.9599408431361829095[8:9]
  4. 4.Normal proportion between valuesAgrees
    Heights are normal with mean 64 in and standard deviation 2.5 in. What proportion lie between 60 and 68 inches?
    Independent answer
    z=±1.6z = \pm 1.6: 2Φ(1.6)−1≈0.89042\Phi(1.6) - 1 \approx 0.8904.
    RatMath code
    stats.normal(64, R`2.5`).prob(60, 68)
    Output
    0.8904014166008840120[7:8]
  5. 5.Inverse normalAgrees
    Scores are normal with mean 500 and standard deviation 100. What score is the 90th percentile?
    Independent answer
    500+1.2816×100≈628.2500 + 1.2816 \times 100 \approx 628.2.
    RatMath code
    stats.normal(500, 100).quantile(R`0.9`)
    Output
    628.15515655446004669367:628.1551565544600466991
  6. 6.CorrelationAgrees
    Find the correlation of (1,2),(2,4),(3,5),(4,4),(5,6)(1, 2), (2, 4), (3, 5), (4, 4), (5, 6).
    Independent answer
    Sxy=8S_{xy} = 8, Sxx=10S_{xx} = 10, Syy=8.8S_{yy} = 8.8: r=8/88≈0.8528r = 8/\sqrt{88} \approx 0.8528.
    RatMath code
    stats.correlation([1, 2, 3, 4, 5], [2, 4, 5, 4, 6])
    Output
    0.85280286542244173719:0.8528028654224417372
  7. 7.ResidualsAgrees
    For the same data the least-squares line is y^=0.8x+1.8\hat y = 0.8x + 1.8. Find the residual at (3,5)(3, 5).
    Independent answer
    y^=4.2\hat y = 4.2; residual 5−4.2=0.85 - 4.2 = 0.8.
    RatMath code
    stats.leastSquares([1, 2, 3, 4, 5], [2, 4, 5, 4, 6]).residuals[2]
    Output
    4/5
  8. 8.Binomial probabilityAgrees
    XX is binomial with n=10n = 10, p=0.3p = 0.3. Find P(X=3)P(X = 3).
    Independent answer
    (103)(0.3)3(0.7)7=0.266828\binom{10}{3}(0.3)^3(0.7)^7 = 0.266828 (exactly 0.26682793200.2668279320).
    RatMath code
    stats.binomial(10, R`0.3`).pmf(3).toDecimal()
    Output
    0.266827932
  9. 9.Binomial cumulativeAgrees
    For the same XX, find P(X≤2)P(X \le 2).
    Independent answer
    0.710+10(0.3)(0.7)9+45(0.09)(0.7)8=0.38278278640.7^{10} + 10(0.3)(0.7)^9 + 45(0.09)(0.7)^8 = 0.3827827864.
    RatMath code
    stats.binomial(10, R`0.3`).cdf(2).toDecimal()
    Output
    0.3827827864
  10. 10.Expected valueAgrees
    A game costs \$1. Roll a die: on a 6 you get \$6 back (a \$5 gain), otherwise nothing. What is the expected gain?
    Independent answer
    5⋅16−1⋅56=05 \cdot \tfrac16 - 1 \cdot \tfrac56 = 0. A fair game.
    RatMath code
    stats.die().mean((x) => (x === 6 ? 5 : -1))
    Output
    0
  11. 11.Conditional probabilityAgrees
    Of 50 students who studied, 45 passed; of 50 who did not, 15 passed. Find P(pass∣studied)P(\text{pass}\mid\text{studied}) and P(studied∣pass)P(\text{studied}\mid\text{pass}).
    Independent answer
    45/50=0.945/50 = 0.9; 45/60=0.7545/60 = 0.75.
    RatMath code
    const table = stats.finite(new Map([[["S", "P"], 45], [["S", "F"], 5], [["N", "P"], 15], [["N", "F"], 35]]), { normalize: true });
    [table.prob(([s, r]) => r === "P", ([s]) => s === "S"), table.prob(([s]) => s === "S", ([, r]) => r === "P")]
    Output
    [9/10, 3/4]
  12. 12.Bayes' ruleAgrees
    A disease affects 1% of people. A test detects it 95% of the time and gives a false positive 5% of the time. Given a positive test, what is the probability of disease?
    Independent answer
    0.00950.0095+0.0495=19118≈0.161\dfrac{0.0095}{0.0095 + 0.0495} = \dfrac{19}{118} \approx 0.161.
    RatMath code
    stats.bayes({ sick: "0.01", well: "0.99" }, { sick: "0.95", well: "0.05" }).posterior.p("sick")
    Output
    19/118
  13. 13.Sampling distribution of the meanAgrees
    A population has mean 50 and standard deviation 12. For samples of 36, find P(xˉ>53)P(\bar x > 53).
    Independent answer
    SE =12/6=2= 12/6 = 2; P(Z>1.5)≈0.0668P(Z > 1.5) \approx 0.0668.
    RatMath code
    stats.normal(50, 2).sf(53)
    Output
    0.066807201268858066:0.06680720126885806601
  14. 14.Confidence interval for a proportionAgrees
    In a poll, 540 of 900 people say yes. Give a 95% confidence interval for the proportion.
    Independent answer
    p^=0.6\hat p = 0.6, SE =0.24/900=0.01633= \sqrt{0.24/900} = 0.01633; 0.6±1.96(0.01633)0.6 \pm 1.96(0.01633): (0.568,0.632)(0.568, 0.632).
    RatMath code
    const ci = stats.proportionInterval(540, 900, { method: "wald" });
    [ci.low, ci.high]
    Output
    [0.567993922157631264639499…, 0.632006077842368735360500…]
  15. 15.Confidence interval for a meanAgrees
    A sample of 16 has mean 25.3 and standard deviation 4.2. Give a 95% tt interval for the mean.
    Independent answer
    t∗=2.131t^* = 2.131 (15 df), SE =1.05= 1.05: 25.3±2.238=(23.06,27.54)25.3 \pm 2.238 = (23.06, 27.54).
    RatMath code
    const ci = stats.meanInterval({ n: 16, mean: "25.3", sd: "4.2" });
    [ci.low, ci.high]
    Output
    [68066944892518025829211/2951479051793528258560, 16255579025646900810785/590295810358705651712]
    meanInterval takes the summary (n,xˉ,s)(n, \bar x, s) directly.
    Fix: ratmath/stats#8, summaries in meanInterval/varianceInterval; closed-form power and sampleSize; fromDensity, transform and orderStatistic
  16. 16.Test for a proportionAgrees
    Test H0:p=0.5H_0: p = 0.5 against p≠0.5p \ne 0.5 when 62 of 100 trials succeed. Give zz and the P-value.
    Independent answer
    z=0.12/0.05=2.4z = 0.12/0.05 = 2.4, P=2(0.0082)=0.0164P = 2(0.0082) = 0.0164.
    RatMath code
    const r = stats.proportionTest(62, 100, R`1/2`);
    [r.statistic, r.pValue]
    Output
    [12/5, 0.01639507184919225888:0.0163950718491922589]
  17. 17.One-sample t testAgrees
    Test H0:μ=5H_0: \mu = 5 against μ≠5\mu \ne 5 for the data 5.1, 4.9, 5.6, 5.8, 6.0, 5.3, 5.5, 5.9.
    Independent answer
    xˉ=5.5125\bar x = 5.5125, s=0.39074s = 0.39074, t=3.710t = 3.710 on 7 df, P≈0.0076P \approx 0.0076.
    RatMath code
    const r = stats.tTest(["5.1", "4.9", "5.6", "5.8", "6.0", "5.3", "5.5", "5.9"], { mu: 5 });
    [r.statistic, r.pValue]
    Output
    [3.7097942125426855917:3.70979421254268559172, 0.0075568702391316313[4:5]]
  18. 18.Goodness of fitAgrees
    A die rolled 60 times gives counts 8, 12, 9, 11, 6, 14. Is it fair? Give χ2\chi^2 and the P-value.
    Independent answer
    Expected 10 each: χ2=42/10=4.2\chi^2 = 42/10 = 4.2, 5 df, P≈0.521P \approx 0.521. No evidence of unfairness.
    RatMath code
    const r = stats.chiSquareTest([8, 12, 9, 11, 6, 14]);
    [r.statistic, r.pValue]
    Output
    [21/5, 0.5209949534314049879[2:3]]
  19. 19.Test of independenceAgrees
    Test whether studying and passing are independent, using the table of exercise 11 (no continuity correction).
    Independent answer
    Expected counts 30, 20, 30, 20: χ2=37.5\chi^2 = 37.5, 1 df, P≈9.1×10−10P \approx 9.1 \times 10^{-10}. Strong evidence of association.
    RatMath code
    const r = stats.chiSquareTest([[45, 5], [15, 35]], { correct: false });
    [r.statistic, r.pValue]
    Output
    [75/2, 0.0000000009141298408[2:3]]
  20. 20.At least oneAgrees
    What is the probability of at least one 6 in four rolls of a die?
    Independent answer
    1−(5/6)4=671/1296≈0.5181 - (5/6)^4 = 671/1296 \approx 0.518.
    RatMath code
    stats.die().power(4).prob((r) => r.includes(6))
    Output
    671/1296