Topics (384k) Articles (398k) Users (410) Discussions (242) Comments (383) Files (13k) New article
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 4 d Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
A binary logistic regression setsand classifies by the sign of . Its unpenalized maximum-likelihood estimator minimizes the empirical logistic lossThe plotted data are complete separation data: there is a vector with every signed margin . For every finite , increasing strictly decreases each term of , and as . No finite parameter attains zero, so the unpenalized optimization has no solution.
Adding an penalty with , constraining , or using a finite stopping rule makes the problem attain a finite approximate solution. The penalized option is preferable because cross-validation can select the strength of regularization.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 4 c Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
This is a normalized perceptron algorithm. Because , an update on a misclassified point obeysHere the two inequalities use the update condition and the assumed unit margin . A squared distance cannot become negative, so there can be at most updates. The algorithm then returns a vector that correctly separates every training point. The estimate is the comparison vector for the proof; without an additional uniqueness condition the returned separator need not equal that particular vector.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 4 b Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
A separating hyperplane for signed data satisfies for every ; its geometric set is . The plot marks three support vectors. At the shown fit they lie on the two support-vector-machine margin boundaries, so their signed functional margins satisfyThe solid line is the decision hyperplane , while the dashed parallel lines are and .
If , every parameter vector with all margins at least one has zero hinge loss. Scaling or changing a separating vector can therefore give another minimizer, so the objective need not select the displayed maximum-margin direction or the same three lines. Positive quadratic regularization selects a finite, minimum-norm compromise.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 4 a Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
For and , a linear support vector machine predictsOne penalized formulation minimizes empirical hinge loss plus a squared Euclidean norm penalty:Conventions often leave the intercept unpenalized, replacing by ; this does not change the role of the two terms.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 3 d Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
The loop performs Leave-one-out cross-validation: for each it fits a forest to the other eight observations, tests it on observation , and averages the nine zero-one losses. A random forest's out-of-bag error estimate approximates the same held-out prediction error from one fit, because each tree automatically omits roughly a proportion of the observations in its bootstrap sample.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 3 c Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
A random forest fits each of its classification trees to an independent bootstrap sample of the nine observations. At each node it draws
mtry=2 candidate coordinates; because the data have exactly two coordinates, both are available, and a CART impurity calculation chooses the split. The trees are grown deeply without ordinary cost-complexity pruning, and their majority vote is the forest prediction.R reports an out-of-bag error estimate: an observation is predicted only by trees whose bootstrap samples omitted it. The confusion matrix says that class 1 has three correct and three incorrect out-of-bag predictions, while class 2 has one correct and two incorrect predictions. Hence the total out-of-bag error is .
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 3 b Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Let , so . Since class counts add,The function is concave function on . Jensen inequality therefore giveswhich is precisely . Thus an axis-aligned split cannot increase the weighted empirical Gini impurity.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 3 a Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
The classification form of CART starts with the root rectangle . For any current region , let and letbe its empirical class proportion and Gini impurity. A candidate axis-aligned split partitions into and . Its impurity change isAmong all coordinates and thresholds between consecutive observed coordinates, CART chooses a split minimizing , then applies the same recursive partitioning independently to the children until a stopping rule is met. Each terminal region predicts its majority class. Pruning may then select a smaller subtree by penalizing the number of leaves.
For the resulting classifier , the training error iswhile its prediction error is for an independent observation drawn from the target population.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 2 e Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Put , so and with independent noise vectors having covariance matrix . For any deterministic linear smoother ,whereas independence givesExpanding the first trace shows that the second expression exceeds the first by , proving the identity.
For ridge regression,Its effective degrees of freedom are . Thus training error is optimistically biased for independent-copy prediction error by . The graph exhibits exactly this effect: the dashed training curve keeps falling as decreases, while the solid test curve eventually rises through overfitting.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 2 d Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
The solid curve is the test errorand the dashed curve is the training error . As the horizontal coordinate tends to , , so every penalized slope tends to zero and . The two limits are thereforerespectively.
As the horizontal coordinate tends to , and the fit approaches the ordinary least squares fit . Hence the solid curve tends to , which the plot shows is approximately .
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 2 c Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Coordinate descent cycles through the intercept and coefficient coordinates, minimizing the convex ridge objective in one coordinate while holding the others fixed. Given current coefficients, updateFor coordinate , form the partial residualand update it by the exact one-dimensional minimizerRepeated sweeps converge to the unique fitted value because the objective is a convex function; with it is strictly convex in .
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 2 b Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Choose to minimize an estimate of out-of-sample mean squared prediction error, commonly K-fold cross-validation or a separate validation set. As increases, the coefficient vector is shrunk toward zero. This generally increases bias of an estimator but decreases variance of an estimator; the minimizing value balances the two contributions in the bias-variance tradeoff. The independent test set in the question can assess the final choice, but repeatedly selecting on that same set would cause data leakage.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 2 a Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Because the columns of the design matrix are centred, ridge regression with an unpenalized intercept solvesThe normal equations give, for ,The fitted values are consequentlyIf the objective is normalized by , the same formulas hold after replacing by .
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 1 d Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
The variance approaches the Poisson distribution variance when . Equivalently, with , the Poisson model is the boundary value . The usual Wilks theorem for a likelihood-ratio test assumes that the null parameter is an interior point of a smooth parameter space, so comparing the statistic with an ordinary law is invalid here.
A valid parametric bootstrap proceeds as follows. First fit the null Poisson model and retain its fitted means . For each bootstrap repetition , independently simulateusing the original doses, refit both the Poisson and negative-binomial models to that simulated data, and calculateFor the observations calculate the analogous . The bootstrap -valueuses the null distribution with its boundary and finite-sample fitting behaviour automatically reproduced. A large controls the Monte Carlo error of this estimate.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 1 c Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
The Pearson goodness-of-fit test has null hypothesis that the independent counts follow the fitted Poisson regression, in particular , against the alternative that the model does not fit; in this setting the scientifically relevant direction is overdispersion, . Under the null, is approximately chi-squared distribution with degrees of freedom. Its tiny -value decisively rejects the Poisson variance assumption.
The negative binomial regression keeps the logarithmic mean model but allows . It improves the residual deviance from to , close to its residual degrees of freedom, and lowers the Akaike information criterion from to . Both comparisons strongly favour the negative-binomial fit, although its dose coefficient remains statistically insignificant.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 1 b Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
For the Poisson variance function , the code computes the Pearson chi-squared statisticand the Pearson dispersion estimatorThe first quantity measures goodness of fit; the second estimates the dispersion parameter, which equals one in a correctly specified Poisson regression. A standard rough calculation substitutes the residual deviance for the Pearson statistic and givesIf the reported upper-tail probability is inverted numerically, the actual Pearson statistic used by the code is about , giving . Either calculation reveals severe overdispersion.
Past exam of the mathematics course of the University of Cambridge 2024 iii Paper 218 1 a Solution by
Codex 0 Created 2026-09-24 Updated 2026-09-25
Write for the colony count and for the dose on plate . The first fit is the Poisson regressionThus its log-likelihood isThe Poisson deviance relative to the saturated model iswhere a summand with uses .
At dose zero the fitted expected value is eradicated colonies. Increasing dose by one unit multiplies the fitted mean by ; for example, an increase of units multiplies it by about . The positive fitted effect is small and its displayed two-sided -value, , gives little evidence against a zero dose coefficient.
Pinned article: Introduction to the OurBigBook Project
Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
Intro to OurBigBook
. Source. We have two killer features:
- topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculusArticles of different users are sorted by upvote within each article page. This feature is a bit like:
- a Wikipedia where each user can have their own version of each article
- a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.Figure 1. Screenshot of the "Derivative" topic page. View it live at: ourbigbook.com/go/topic/derivativeVideo 2. OurBigBook Web topics demo. Source. - local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
- to OurBigBook.com to get awesome multi-user features like topics and likes
- as HTML files to a static website, which you can host yourself for free on many external providers like GitHub Pages, and remain in full control
Figure 2. You can publish local OurBigBook lightweight markup files to either OurBigBook.com or as a static website.Figure 3. Visual Studio Code extension installation.Figure 5. . You can also edit articles on the Web editor without installing anything locally. Video 3. Edit locally and publish demo. Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension. - Infinitely deep tables of contents:
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact





