CS230 — Original on-site preparation

Independent written study. All essential explanations and optional model reasoning for this chapter are on this page. References are optional further study. No degree, professional approval or observed competence is conferred.

Fit a probability model without confusing it with evidence about the world

A parameter belongs to a specified model; an estimator is a rule that maps a sample into a parameter estimate. An estimate is the value that rule produces on one observed sample. These are different objects. For independent Bernoulli observations, a model uses a common probability p for each binary outcome. If a fictional sample has eight successes and twelve failures, the likelihood of its particular ordered sequence is p⁸(1−p)¹². The count likelihood includes a binomial coefficient, but that coefficient does not depend on p and therefore leaves its maximizing value unchanged.

Likelihood treats the observations as fixed and varies the parameter. It is not a probability distribution over the parameter and need not integrate to one over parameter space. A posterior distribution additionally requires a prior and Bayes' rule; maximum a posteriori estimation and maximum likelihood are different procedures. A constant prior in one coordinate need not remain constant after reparameterization. Calling a prior flat therefore does not eliminate assumptions.

Using natural logarithms, the negative log-likelihood is ℓ(p)=−8 ln p−12 ln(1−p). On 0<p<1, its derivative is −8/p+12/(1−p). Setting it to zero gives 20p=8, hence p̂=.4. The second derivative 8/p²+12/(1−p)² is positive, so this is the unique minimum in the interior; endpoints assign zero probability to this mixed sample. For an all-success sample the constrained maximum is at p=1 instead. An unconstrained numerical update can leave [0,1], so domain handling is part of an implementation, not a cosmetic check.

Independent observations let products become sums of log probabilities. This avoids direct multiplication of many tiny numbers and makes derivatives easier to accumulate. Differentiating a negative log term retains its leading minus sign: d[−ln q(p)]/dp=−q′(p)/q(p). Specify the logarithm base: natural logarithms measure information in nats; base two measures bits. Changing base rescales the objective but does not change its unpenalized maximizer. Continuous likelihood uses densities at the observed values; a density's value is not the probability of observing that exact point. Its units and coordinate transformation matter.

Conditioning, smoothing and a naive Bayes model

For a class C and observed features x, Bayes' rule is P(C|x)=P(x|C)P(C)/P(x), provided P(x)>0. A naive Bayes model assumes features are independent conditional on the class, giving score s(C)=P(C)∏j P(xⱼ|C). It does not assert that features are independent in the pooled population. Include the class prior once. Comparing scores selects a class; normalizing by their sum produces this model's posterior probabilities. Neither result establishes real-world calibration.

Use fictional urgent and routine cases with priors .2 and .8. Two binary indicators are present. Their conditional presence probabilities are [.8,.6] for urgent and [.1,.2] for routine. The unnormalized scores are .2×.8×.6=.096 and .8×.1×.2=.016; normalization gives urgent probability 6/7. This uses the declared conditional-independence assumption. If the second indicator merely copies the first, multiplying them as independent evidence double-counts information. A well-formed probability output can then be overconfident. Duplicating a field must not manufacture an independent observation.

A zero estimated probability makes a product zero, even if the unseen value was simply absent from a small training sample. For a Bernoulli feature, adding a positive pseudocount a to each of its two outcomes gives (k+a)/(n+2a) for presence and (n−k+a)/(n+2a) for absence. With k=0,n=8,a=1, these become .1 and .9. This is a deliberate estimation rule, not proof that the presence rate is actually .1. Fit counts and any smoothing choice in development data. In a log implementation, sum log priors and log conditional probabilities, and use stable normalization; distinguish an impossible event under the chosen model from arithmetic underflow.

Compare estimators under an explicit repeated-sampling target

For a fixed true parameter θ, bias is E[θ̂]−θ, variance is E[(θ̂−Eθ̂)²], and mean squared error is E[(θ̂−θ)²]. Expanding the square gives MSE=variance+bias². There is no additional random-parameter noise term in this fixed-parameter identity. Predicting a new noisy outcome is a different problem and can include irreducible outcome variance. The standard deviation of an estimator's sampling distribution is its standard error; it differs from the standard deviation of individual observations.

A constructed comparison makes the tradeoff visible. Estimator A has bias zero and variance nine, so MSE is nine. Estimator B has bias one and variance four, so MSE is five. Under squared-error loss B is preferable despite being biased. This does not establish that B is preferable under every loss or that either estimator repairs selection bias in a real sample. More rows cannot turn a systematically selected population into a representative one by arithmetic alone.

Intervals and tests describe procedures under assumptions

For independent, identically normally distributed observations with a common unknown mean and variance, the sample mean has estimated standard error s/√n, where s²=Σ(xᵢ−x̄)²/(n−1). The statistic (x̄−μ)/(s/√n) has a Student t distribution with n−1 degrees of freedom. A two-sided 95% confidence procedure uses x̄±t*.975,n−1 s/√n. The normal critical value 1.96 is a large-sample approximation, not an exact finite-sample replacement. Dependence, selection, heavy tails and model changes require examination before applying the formula.

For an explicitly constructed normal-sampling record with n=25,x̄=12,s=5, the standard error is one. Using the supplied t critical value 2.064 for 24 degrees of freedom gives [9.936,14.064]. A 95% confidence claim refers to coverage of the procedure over repeated samples under the model. It does not assign a 95% posterior probability to the fixed mean after seeing this one interval. It does not mean 95% of individual observations lie inside the interval, and it does not account for an unmodeled selection mechanism.

A hypothesis test declares a null, alternative, statistic and rejection rule. The significance level α controls the probability of a Type I error under the null according to the test's assumptions; it is not the probability that the null is true. A p-value is a tail probability of results at least as extreme under the specified null. The tail depends on the prespecified one- or two-sided alternative. Failing to reject does not prove equivalence. Power is the probability of rejecting at a specified alternative effect and depends on sample size, variability and the rule. Plan it for meaningful effect sizes; it is not a universal property of a dataset.

Report estimated effects, denominators and uncertainty alongside decisions. Repeatedly trying endpoints, subgroups or stopping times and reporting only a small p-value changes the selection procedure. A nominal .05 threshold alone does not address that search. Random assignment can support a causal comparison; random sampling addresses population representation. Neither makes two observed groups numerically identical or removes measurement error by declaration.

Optional changed record and complete reasoning

A new independent Bernoulli sample contains twelve successes and eight failures. Fit p by maximum likelihood. In the two-indicator model, keep priors and first-indicator rates, but change the second-indicator rates to .3 for urgent and .4 for routine. Recompute the normalized urgent probability. Finally a normal-sampling record has n=16,x̄=10,s=4; use the supplied 15-degree-of-freedom 95% t critical value 2.131.

The negative log-likelihood derivative is −12/p+8/(1−p); the interior minimum is p̂=.6. It estimates a model probability from this sample and does not establish a causal improvement over the earlier .4 sample. The new class scores are .2×.8×.3=.048 and .8×.1×.4=.032. Their sum is .08, giving urgent probability .6. The changed conditional evidence changes the result despite unchanged priors. If the indicators are dependent within a class, these numbers remain only the fitted naive model's calculation.

The new standard error is 4/√16=1, so the confidence interval is [7.869,12.131]. Comparing these endpoints with the earlier record does not by itself supply a test of the difference between population means. The two sampling designs, dependence and a difference-estimator standard error must be specified. A narrow interval or a larger point estimate cannot substitute for that design.

Optional criteria: distinguish likelihood from posterior; derive the Bernoulli estimate with its domain; compute and normalize class scores while stating conditional independence; calculate the interval and explain coverage and causal limits. Award one point for each fully explained criterion.

Optional source references

These sources support the explanations; reading them is optional. Original Academy examples are fictional. Historical attributed readings remain preserved.