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.Mean and standard deviationAgreesFor the data 2, 4, 4, 4, 5, 5, 7, 9 find the mean, the sample standard deviation and the population standard deviation.Independent answerMean 5; squared deviations sum to 32; ; .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.z-scoresAgreesA test has mean 72 and standard deviation 8. What is the z-score of a mark of 86?Independent answer.RatMath code
R`(86 - 72)/8`Output7/4
- 3.Normal probabilityAgreesFind for a standard normal , to four decimals.Independent answer0.9599 (table: 0.95994).RatMath code
stats.normal().cdf(R`7/4`)Output0.9599408431361829095[8:9]
- 4.Normal proportion between valuesAgreesHeights are normal with mean 64 in and standard deviation 2.5 in. What proportion lie between 60 and 68 inches?Independent answer: .RatMath code
stats.normal(64, R`2.5`).prob(60, 68)Output0.8904014166008840120[7:8]
- 5.Inverse normalAgreesScores are normal with mean 500 and standard deviation 100. What score is the 90th percentile?Independent answer.RatMath code
stats.normal(500, 100).quantile(R`0.9`)Output628.15515655446004669367:628.1551565544600466991
- 6.CorrelationAgreesFind the correlation of .Independent answer, , : .RatMath code
stats.correlation([1, 2, 3, 4, 5], [2, 4, 5, 4, 6])Output0.85280286542244173719:0.8528028654224417372
- 7.ResidualsAgreesFor the same data the least-squares line is . Find the residual at .Independent answer; residual .RatMath code
stats.leastSquares([1, 2, 3, 4, 5], [2, 4, 5, 4, 6]).residuals[2]Output4/5
- 8.Binomial probabilityAgreesis binomial with , . Find .Independent answer(exactly ).RatMath code
stats.binomial(10, R`0.3`).pmf(3).toDecimal()Output0.266827932
- 9.Binomial cumulativeAgreesFor the same , find .Independent answer.RatMath code
stats.binomial(10, R`0.3`).cdf(2).toDecimal()Output0.3827827864
- 10.Expected valueAgreesA 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. A fair game.RatMath code
stats.die().mean((x) => (x === 6 ? 5 : -1))Output0
- 11.Conditional probabilityAgreesOf 50 students who studied, 45 passed; of 50 who did not, 15 passed. Find and .Independent answer; .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.Bayes' ruleAgreesA 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.RatMath code
stats.bayes({ sick: "0.01", well: "0.99" }, { sick: "0.95", well: "0.05" }).posterior.p("sick")Output19/118
- 13.Sampling distribution of the meanAgreesA population has mean 50 and standard deviation 12. For samples of 36, find .Independent answerSE ; .RatMath code
stats.normal(50, 2).sf(53)Output0.066807201268858066:0.06680720126885806601
- 14.Confidence interval for a proportionAgreesIn a poll, 540 of 900 people say yes. Give a 95% confidence interval for the proportion.Independent answer, SE ; : .RatMath code
const ci = stats.proportionInterval(540, 900, { method: "wald" }); [ci.low, ci.high]Output[0.567993922157631264639499…, 0.632006077842368735360500…]
- 15.Confidence interval for a meanAgreesA sample of 16 has mean 25.3 and standard deviation 4.2. Give a 95% interval for the mean.Independent answer(15 df), SE : .RatMath code
const ci = stats.meanInterval({ n: 16, mean: "25.3", sd: "4.2" }); [ci.low, ci.high]Output[68066944892518025829211/2951479051793528258560, 16255579025646900810785/590295810358705651712]
meanIntervaltakes the summary directly.Fix: ratmath/stats#8, summaries inmeanInterval/varianceInterval; closed-formpowerandsampleSize;fromDensity,transformandorderStatistic - 16.Test for a proportionAgreesTest against when 62 of 100 trials succeed. Give and the P-value.Independent answer, .RatMath code
const r = stats.proportionTest(62, 100, R`1/2`); [r.statistic, r.pValue]Output[12/5, 0.01639507184919225888:0.0163950718491922589]
- 17.One-sample t testAgreesTest against for the data 5.1, 4.9, 5.6, 5.8, 6.0, 5.3, 5.5, 5.9.Independent answer, , on 7 df, .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.Goodness of fitAgreesA die rolled 60 times gives counts 8, 12, 9, 11, 6, 14. Is it fair? Give and the P-value.Independent answerExpected 10 each: , 5 df, . 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.Test of independenceAgreesTest whether studying and passing are independent, using the table of exercise 11 (no continuity correction).Independent answerExpected counts 30, 20, 30, 20: , 1 df, . 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.At least oneAgreesWhat is the probability of at least one 6 in four rolls of a die?Independent answer.RatMath code
stats.die().power(4).prob((r) => r.includes(6))Output671/1296