Software defects can make a scientific result wrong even when another researcher reproduces it exactly. Reducing their impact requires both a traceable computational workflow and independent checks that its implementation and scientific assumptions are appropriate.
Terminology should be stated because usage varies. Here, computational reproducibility means obtaining consistent results from the same data and recorded computational procedure; scientific replication means testing the finding with newly collected data or an independently conducted study. model verification asks whether the code implements the intended equations and rules. model validation asks whether those equations and rules are adequate for the scientific use. A result can pass the first two computational checks and still fail biological validation. Conversely, floating-point differences between platforms need not invalidate a conclusion if they lie within a justified numerical or statistical tolerance.
A software bug can enter at every stage. A sample-order mismatch may associate measurements with the wrong labels while retaining plausible matrix dimensions. An indexing or sign error can reverse a treatment contrast. Unit conversion errors can alter a kinetic rate by orders of magnitude. A mistaken stopping rule can report an optimizer's initial value as its solution. A preprocessing script can leak test-set information into training and exaggerate predictive accuracy. These failures are dangerous because an apparently reasonable plot and a successful program exit are weak tests of correctness.
Data handling provides a documented biological example. Spreadsheet defaults can coerce identifiers into dates or numbers: historical gene symbols such as SEPT2 and MARCH1 are examples of this problem. A survey found such conversions in published supplementary gene lists, demonstrating that silent changes can propagate beyond the originating analysis.[ref]
Gene name errors are widespread in the scientific literature by Mark Ziemann and others. Abstract; examples of gene-symbol conversion and manual verification of affected supplementary files
Automatic conversion may be intended spreadsheet behavior, but it becomes a defect in an analysis that requires exact textual identifiers. Specifying identifier columns as strings, preserving stable accessions, checking uniqueness and matching against an expected identifier set directly address that failure mode.A second example distinguishes coding errors from modeling errors. The AFNI 3dClustSim program had a defect in variance rescaling after smoothing, associated with boundary effects. Its maintainers documented the repair and assessed its consequences. Their analysis also showed why the broader problem of inflated cluster-inference false positives could not be attributed to that defect alone: assumptions about spatial autocorrelation and the inferential procedure mattered as well.[ref]
FMRI Clustering in AFNI: False-Positive Rates Redux by Robert W. Cox and others. Results, “The past, I: 3dClustSim, and ‘The Bug’”; Discussion, effect of the correction
Thus correcting an implementation is necessary but does not automatically validate the statistical method it implements.The first defense is a clear, inspectable specification. Write down units, array meanings, intended inputs and limiting behavior; divide a pipeline into small components with explicit interfaces. A unit test for a decay solver can compare against . An integration test should check the connection between data import, model fitting and plotting, including sample identifiers and units. regression tests preserve justified behavior after a fix, but a saved output from an unexamined older version is not an independent truth standard. Test quality matters more than the percentage of lines executed.
Exact reference answers are often unavailable, so property-based testing and metamorphic testing are valuable. A closed chemical conversion should conserve total material; a probability vector should be nonnegative and sum to one; consistently permuting independent sample rows should leave a deterministic fitted model unchanged. A valid metamorphic relation must match the problem: permuting a time series would generally destroy temporal information rather than preserve the expected result. Testing extreme inputs, empty groups and zero-rate cases often exposes bugs that ordinary examples miss. Code review and an independently written implementation can find shared blind spots that additional tests derived from the same erroneous formula cannot.[ref]
Best Practices for Scientific Computing by Greg Wilson and others. sections on modular development, testing, assertions and collaborative code review
Numerical algorithms introduce another layer. For explicit Euler integration of , the update is . The exact solution is positive and decays, but makes the discretization unstable, and even produces alternating negative values. This can be an unsuitable algorithm or step size rather than a typographical defect. Comparing step sizes, solver tolerances and alternative algorithms separates discretization error from a biological prediction. In a sensitive dynamical system, convergence of statistical summaries may be more meaningful than exact agreement of a long trajectory.
Traceability makes failures discoverable and corrections usable. version control identifies the code revision that generated a result; data provenance records raw inputs, reference annotations, filtering decisions and transformations. An executable workflow regenerates outputs from those inputs without undocumented manual edits. Dependency versions and a recorded environment, possibly a software container, reduce accidental differences between installations. A random seed should be recorded together with the generator and, where relevant, the allocation of streams to parallel workers. One seed is not an uncertainty estimate, and parallel scheduling or library changes can defeat bitwise repetition even when it is reused.
continuous integration can run focused tests whenever the analysis changes, while release notes and archived versions let readers distinguish corrected results from earlier ones. The environment archive preserves the ability to reproduce an old computation; the maintained version should also contain the scientific correction. Publishing only a container that reliably reproduces a wrong result is inadequate. When a defect is found, quantify which conclusions change, rerun affected analyses, retain a minimal reproducing example and communicate the correction through the appropriate scientific record. Reliable computational science combines reproducible execution, verified implementation, quantified numerical error and validation against evidence; none is a substitute for the others.
Past exam of the systems biology course of the University of Cambridge 2024 Paper 3 2 d Solution 2026-10-20
TODO: Complete the data-specific numerical results and diagnostics when the original
Iris_data.csv is available.Use the random-walk Metropolis algorithm with proposal , where . The proposal is symmetric, so for a nonnegative proposal the acceptance probability isNegative proposals are rejected. They are not redrawn until positive, since that would change the proposal kernel and require a different acceptance ratio. On rejection, store the current state again; keeping accepted moves alone would bias the empirical posterior distribution.
set.seed(20240528)
B <- 10000L
mu <- numeric(B + 1L)
mu[1L] <- 4
logpost <- function(u) {
if (!is.finite(u) || u < 0) return(-Inf)
loglik(u) - u/3
}
lp <- logpost(mu[1L])
accepted <- 0L
for (i in seq_len(B)) {
proposal <- rnorm(1L, mean = mu[i], sd = 1)
lp_new <- logpost(proposal)
if (log(runif(1L)) < min(0, lp_new - lp)) {
mu[i + 1L] <- proposal
lp <- lp_new
accepted <- accepted + 1L
} else {
mu[i + 1L] <- mu[i]
}
}
cat("Acceptance fraction =", accepted/B, "\n")
# A provisional discard; assess it with the trace in part (e).
burn <- 1000L
post <- mu[(burn + 2L):(B + 1L)]
m <- xbar - 1/(3*n)
s <- 1/sqrt(n)
posterior_density <- function(u) {
ans <- numeric(length(u))
ok <- u >= 0
ans[ok] <- exp(dnorm(u[ok], m, s, log = TRUE) -
pnorm(m/s, log.p = TRUE))
ans
}
png("q2-posterior.png", width = 900, height = 600)
hist(post, breaks = 40, probability = TRUE, xlab = expression(mu),
main = "Retained Metropolis draws and exact posterior")
u <- seq(0, max(post) + 3*s, length.out = 4001L)
lines(u, posterior_density(u), col = "firebrick", lwd = 2)
dev.off()The exact truncated normal distribution density overlays the histogram as a check; it does not replace the requested Markov chain Monte Carlo procedure. The 9,000 retained states exclude the initial state and the first 1,000 transitions. The particular histogram and acceptance fraction remain dependent on the missing measurements.
A good receiver operating characteristic rises toward the upper-left corner: many reference-positive loci are detected while few reference-negative loci are accepted. The area under the ROC curve summarizes this discrimination over cutoffs. Higher is better in the stated score direction; perfect separation gives one. The displayed value near 0.86 indicates substantial ranking discrimination against this reference.
The area can also be interpreted as the probability that a randomly chosen positive receives a higher score than a randomly chosen negative, with half credit for ties. It does not select a cutoff or demonstrate that most retained calls are correct: those practical questions also depend on prevalence and the relative costs of errors.
The same illustrative classifier viewed through ROC and precision–recall curves at ten percent prevalence
. Details. An ensemble of normalized quantum states with probabilities is represented by the density operatorIt determines every observable expectation value through . The ensemble decomposition need not be unique; the operator specifies the measurement statistics.
The original Von Neumann entropy depends on its eigenvalues, with defined by continuity:After rank-one dephasing, the eigenvalues are the retained diagonal populations , givingdephasing removes coherences in the specified basis, increasing the system's mixedness while preserving those measurement probabilities. It cannot be a closed-system unitary transformation, since the eigenvalues change. The subsystem entropy increase does not by itself assert an increase in the entropy of a closed system plus its environment.
A scattering phase shift measures the change of a partial wave's outgoing phase relative to the free radial solution. For a real central potential and elastic scattering, probability conservation gives a unit-modulus Partial-wave S-matrix . Indeedso the incoming amplitude is unchanged and the outgoing one acquires .
Expanding an incident plane wave in Legendre polynomials and comparing the outgoing spherical wave givesUse and to remove cross terms:This is the elastic total scattering cross-section for the one-particle central-potential problem, with no identical-particle symmetrization factor.
Let . The outgoing analytic branch of Klein-Gordon step momentum iswhere each square root is continued from the upper half-plane. It behaves as at large positive or negative real . The branch points are ; replacing this product by a principal square root of can choose the wrong sign below the lower threshold.
I. For , and both transmitted kinetic energy and group velocity are positive. Thus and ; the transmission decreases to zero on approaching the upper threshold from above.
II. For , write with . The right wave decays, has modulus one, and . There is an evanescent tail but no flux transmitted to infinity. Its reflection quantum phase changes continuously between the two thresholds.
III. For , the analytic continuation gives , where . The group velocity is again rightward, while the charge density and transmitted charge current are negative. ThereforeChoosing would describe a wavepacket arriving from the right, inconsistent with the chosen incoming channel. As the lower threshold is approached, and from above. This Klein-Gordon step amplification has a real denominator zero at when : there , and no finite stationary solution with unit incoming amplitude satisfies both matching equations. The resulting formal pole must not be described as an infinite single-particle probability. Finite switching, wavepackets and the treatment of the external source require a multiparticle analysis.[ref]
Klein Paradox for Spin-0 Particles by Douglas M. Gingrich. Equations 4.142–4.155: outgoing negative-momentum branch, boundary matching and charge currents
The negative-kinetic-energy branch is interpreted as an antiparticle channel. In the overlap , particles can escape to the left and oppositely charged antiparticles to the right. This interval exists only when . The external electrostatic source supplies the energy for pair creation; the reflected particle flux can exceed the incident one because the outgoing state need not contain only the incident particle.
The conserved quantity is signed charge current, not a positive one-particle probability in both regions. Negative denotes rightward transport of opposite charge, so it is consistent with and . A quantized charged field with particle and antiparticle creation operators gives the appropriate interpretation of this Klein paradox. This bosonic result must not be replaced by a fermionic reflection law or interpreted as a failure of charge conservation.[ref]
Klein Paradox for Spin-0 Particles by Douglas M. Gingrich. Discussion after equation 4.155: pair creation and the oppositely signed transmitted current
Use normalized instantaneous modes and expand . Differentiating at fixed givesFor , integration usesso the moving-wall derivative coupling isFor the normalization derivative and the remaining integral cancel exactly, giving zero. The moving integration endpoint contributes no boundary term because every mode vanishes there. ThereforeThe real coupling matrix is antisymmetric, as required by conservation of total probability.
For first-order excitation in a linearly expanding infinite well, retain only the ground-state amplitude on the right. For the second level, the coupling coefficient is . With ,The relative dynamical phase is plus a constant. Up to an irrelevant phase,The lower endpoint is an oscillatory improper limit: substituting gives . A physical initial state cannot occupy a zero-width well. Prepare the ground state at , integrate from , and then take the formal limit of the probability. For , endpoint asymptotics give ; the first-order expression is reliable only while total excitation remains small.
Multiply each time-sliced path weight by . A nonnegative finite is a local killing rate: the Feynman-Kac weight attenuates paths in proportion to the time spent in regions where . Let that rate tend to infinity outside the allowed interval. Paths that exit are removed, leaving Brownian motion killed at its first boundary hit.
Consequently the required kernel is the Gaussian path measure restricted to surviving paths, equivalentlywith the infinite-barrier interpretation stated above. It solves in the interior with absorbing Dirichlet boundary conditions at . A reflecting boundary condition for a diffusion would describe a different process.
Strictly, this is a transition probability density in the final position, jointly with survival; a probability for an interval of final positions includes an integral over . Its integral over the whole allowed interval is at most one. It is not the normalized endpoint density conditional on survival, which would require division by the survival probability. In these diffusion units and the eigenvalues of have units of inverse time.
The survival probability from an absorbing transition density follows by integrating over final position. Sincethe exact survival probability for isThe slowest Dirichlet mode dominates at large time:The first relative correction is . The approximation is a late-time result; extrapolating its prefactor to would incorrectly give a probability larger than one. The full alternating series tends to one there.
Original absorbing-interval transition densities and the approach of the survival probability to its slowest-mode asymptote
. Details. Choose orthonormal, flux-normalized incoming and outgoing channels and include all channels of this lossless scattering problem. Conservation of probability requires for every input vector. With ,For a square channel matrix this also gives . A submatrix obtained by omitting loss channels need not be unitary, but that is not the stated two-channel model.
The given real Hadamard matrix is symmetric, unitary and its own inverse. HenceThis same transformation preserves the canonical commutation relations for bosons and anticommutation relations for fermions. To extract probabilities one must use normalized number states, including their factorial factors, even when the supplied input expression is unnormalized.
For identical fermions, and . ThereforeThe minus sign is a global phase for this output. The only occupancy is , with probability one. Double occupancy of either specified single-particle mode is excluded; no extra internal states are present in this model.
The input squared norm is , so divide its stated expression by . Commutativity and the inverse channel transformation give the normalized outputAfter the binomial expansion, the coefficient of isHence every possible occupancy has even particle number in each port:All other occupancies have zero probability. The normalization identityfollows by taking the coefficient of in . For it reduces to (c), and symmetry under gives equal mean occupancies in both outputs.
Original balanced-splitter occupations for two-particle statistics and twin-Fock bosons, with independent distinguishable-particle comparisons
. Details. On periodic ring states the angular-momentum index is an integer. At the stated resonance,so is the identity on every orbital state. After steps from the normalized ground state,Its phase varies in space but its position probability density remains uniform. Periodicity permits integration by parts, givingConsequentlyEquivalently, the angular-momentum probabilities are , with . The mean angular momentum remains zero while its variance grows as . This quantum resonance of the kicked rotor gives coherent ballistic energy growth. The Bessel second-moment identity connects the momentum spreading to that quadratic energy law; an incoherent random walk would instead give linear energy growth.
Original resonant kicked-rotor calculation: angular-momentum probabilities and the quadratic kinetic-energy law
. Details. A Klein-Gordon solution is second order in time: both and are needed as initial data. Its free modes have both signs of frequency,This differs from the first-order Schrödinger evolution of a fixed one-particle wavefunction.
Moreover, does not generally obey the required probability continuity equation. The conserved Klein-Gordon density is proportional toup to a positive conventional constant. A pure positive-frequency mode gives and a negative-frequency mode gives . This density is not positive definite and cannot be a universal position probability density.
For a free field, one can choose a positive-frequency subspace with a positive integrated inner product. Time-dependent backgrounds generally mix it with the negative-frequency subspace, so simply deleting the latter is not dynamically consistent. In quantum field theory the complex Klein-Gordon field instead has particle and antiparticle sectors; its conserved current is interpreted as charge current, and creation or annihilation of pairs need not fit a fixed-particle-number wavefunction. These are limitations of the naive single-particle interpretation, not a failure of the relativistic field equation.
For this mode, abbreviateThe electric pulse is . In temporal gauge the mode equation has a finite step in its frequency squared, with no delta multiplying the mode. Thus both and its first time derivative are continuous at zero.
Writing the positive-frequency incident amplitude as , the matched solution isIts initial value is and its initial derivative is , as required. In the normalized outgoing-frequency basis it isThe negative-frequency contribution appears even though only positive frequency was incident. These are temporal-mode matching coefficients, so their conserved difference is hyperbolic rather than the sum-one rule of ordinary spatial reflection and transmission probabilities.
Past exam of the theoretical physics II course of the University of Cambridge 2017 2 e Solution 2026-10-18
For , the quantum Gibbs state is diagonal in the basis. Its two probabilities are proportional to . ThusAt small inverse temperature, . As a function of , the normalized spin component is the smooth odd curve : it crosses zero at and saturates at . As a function of its direction is reversed if . For , positive temperature favors , while negative temperature gives the inverted population.
Past exam of the theoretical physics II course of the University of Cambridge 2019 4 a Solution 2026-10-18
A quantum state ensemble of normalized states , with probabilities and , has density operatorIt is a positive semidefinite Hermitian operator with trace one, and the Born rule assigns a measurement outcome with projector the probability .
A pure state has , hence and purity of a density operator . Its only nonzero eigenvalue is one. A mixed state has at least two nonzero eigenvalues and . The spectral theorem proves the converse criteria, since the nonnegative eigenvalues sum to one. Different quantum state ensembles may give the same density operator; the mere presence of several terms in a preparation list does not make the state mixed if all positive-weight terms represent the same quantum state ray.





