Fit an offset at every frequency
Write each observation as a constant offset plus cosine and sine components and an error. At a fixed frequency this is linear in three unknown coefficients. The cosine and sine together allow any sinusoidal phase. Quoted standard errors supply inverse-variance weights when errors are independent and Gaussian.
A sample mean can differ from the true mean if visits miss part of a cycle. Subtracting it once and forcing the fitted wave through zero can suppress a real signal. Let the constant float with each trial frequency instead. This is the generalized, or floating-mean, Lomb–Scargle fit.
Keep times in days and frequency in cycles per day. The browser fits normalized linear intensity; the real tutorial fits I-band magnitudes. Both are numerical sinusoid fits, but their amplitudes describe different physical quantities.
Reading: Zechmeister & Kürster, generalized Lomb–Scargle, arXiv v1 · VanderPlas, Understanding the Lomb–Scargle Periodogram, arXiv v1
Eliminate the constant, then solve two equations
A derivative measures how the mismatch changes when one coefficient is nudged. At a smooth minimum that first-order change is zero. Differentiating a squared residual brings down twice the residual, multiplied by the negative coefficient of the nudged term. Setting each resulting weighted sum to zero gives the fit equations.
Normalize the inverse-variance weights so their sum is one. Call the weighted means of the data, cosine and sine Y, C and S. Setting the derivative with respect to the constant to zero gives the constant as the data mean minus the two fitted trigonometric means.
Substituting that constant centers both trigonometric columns. Define CC and SS as their weighted squared deviations, CS as their weighted cross product, and YC and YS as their cross products with the centered data. Differentiating with respect to the remaining coefficients gives two simultaneous equations.
Multiply the first equation by SS and the second by CS, then subtract to isolate a. Reverse that elimination to get b. The determinant vanishes if the sampled trigonometric columns supply no independent information at that frequency; the program then skips that trial.
Reading: Zechmeister & Kürster, generalized Lomb–Scargle, arXiv v1 · VanderPlas, Understanding the Lomb–Scargle Periodogram, arXiv v1
Turn fit improvement into a periodogram
Fit a constant-only reference using the same weights. At each frequency compare its squared residual sum with the best sine/cosine/constant fit. Divide the improvement by the reference value. The resulting standard power lies between zero and one: zero means no improvement, one means a perfect fit to the samples.
A power of 0.9 is not a ninety-percent chance that a period is correct. With few points, a flexible sinusoid can achieve large improvements even for noise. Searching more frequencies offers more chances to find a high peak.
A finite observing span makes narrow frequency structure on a scale comparable to one divided by that span. Use several grid points across it. The real replay chooses a spacing one fifth of that scale and saves its full frequency grid. The frequency limits are declared choices tied to the physical question.
Reading: Astropy 8.0.2 Lomb–Scargle documentation · VanderPlas, Understanding the Lomb–Scargle Periodogram, arXiv v1
Calibrate the maximum over the whole search
The null model for the replay is a constant source with independent Gaussian errors of the quoted sizes. Draw one noisy value at each actual timestamp, fit every declared frequency, and save the largest power. Repeat this entire process many times. The distribution of maxima includes both the observing window and the number of frequencies searched.
Count null maxima at least as high as the measured maximum. With B trials and K exceedances, the finite Monte Carlo rank below provides a nonzero result even if no exceedance is seen. Its numerical resolution is about one over B. A very small claimed false-alarm probability requires many trials; a short simulation cannot certify an arbitrarily rare tail.
Use an independent noise sample to test the chosen threshold. The real-data tutorial calibrates a five-percent threshold using 4096 null searches and tests it with 1024 fresh searches. The observed held-out rates are 4.39 and 4.49 percent for the full and sparse timestamp patterns. These checks address the declared independent-Gaussian model; red noise or shared calibration errors require another null model.
Reading: Astropy 8.0.2 Lomb–Scargle documentation · VanderPlas, Understanding the Lomb–Scargle Periodogram, arXiv v1
Worked comparison: a higher peak can mean weaker evidence
The frozen OGLE first-season sample has twenty-five measurements. Its maximum power is 0.6418 and the finite Gaussian-null tail rank is 0.004882. Keeping every third measured point leaves nine points. Their maximum power rises to 0.8992, yet the corresponding tail rank rises to 0.2060.
The sparse fit explains more of its selected samples, but noise with only nine samples also fits impressively somewhere in this wide search. Comparing peak heights without recalibrating the sampling would reverse the lesson. The two actual timestamp patterns each receive their own null simulation and use the same explicit search grid.
The synthetic browser examples below provide a separate controlled comparison. Their known source period lets us label the once-nightly alias directly.
| Schedule | Exposures | Strongest period (days) | Flash triggers |
|---|---|---|---|
| Once nightly | |||
| Three visits per night | |||
| Jitter and gaps | |||
| Missed flash | |||
| Caught flash |
Reading: OGLE-IV LMC RR Lyrae official data README · Zechmeister & Kürster, generalized Lomb–Scargle, arXiv v1 · Astropy 8.0.2 Lomb–Scargle documentation
Count wrong aliases separately from missed signals
A false-alarm rate asks how often noise is mistaken for a detection. It does not tell us how often a real signal is missed or assigned a wrong period. Inject a specified signal into new noise at the same timestamps, run the unchanged search and threshold, and compare the recovered frequency with the known input.
The real replay uses 128 synthetic sinusoidal magnitude signals with semi-amplitude 0.1 mag, random phases and frequencies between 0.3 and 4.8 cycles per day. A correct recovery lies within one inverse baseline of the injected frequency. In the full twenty-five-point schedule, 112 injections cross threshold: 36 choose the correct-frequency neighborhood and 76 choose another alias. Sixteen miss threshold.
Those counts describe that signal family, amplitude, frequency range and error model. A different population needs another injection experiment. The distinction is useful even before a population model is finalized: a detection threshold and a period-identification rule answer different questions.
Reading: VanderPlas, Understanding the Lomb–Scargle Periodogram, arXiv v1 · Astropy 8.0.2 Lomb–Scargle documentation