Lesson 19 / Bias, Overfitting, and Out-of-Sample Testing
After trying twenty times, can you say you tested the idea only once?
Keep every attempt and distinguish development, selection, and data that played no part in either. Consider how much chance can contribute to a winning result.
What you will learn
- Identify look-ahead bias and research choices
- Split data chronologically according to their role
- Record when test feedback becomes part of development
Allow about 30–45 minutes. The exercises use fictional data. The page checks structured answers in your browser. Export your work before refreshing.
Start with the concepts ↓Bias can enter before you plot a curve
Look-ahead bias uses information unavailable at the time. Survivorship bias keeps only the assets that survived to the present. Both can affect a backtest with correct accounting code.
Repeatedly changing windows, assets, dates, and metrics can overfit chance patterns in the past. Hand-picking another filter is also a selection decision.
Multiple tests increase the chance of a false positive
Suppose tests are independent, every null hypothesis is true, and each test has a 5% false-positive rate. The probability of at least one false positive in n tests is 1 − 0.95ⁿ. For 20 tests it is about 64.15%.
Strategy trials are often dependent and may not match this test setup. The example illustrates how more attempts create more chances for a spurious success. It gives no strategy-specific probability of overfitting.
The role of a test depends on how it is used
Use periods 1–6 for development, 7–8 for selection, and 9–10 for the first evaluation after freezing the rule. If you use the results from 9–10 to add a filter, those periods become part of the new version's development.
Retain the original version's first test result. Record the revised version's performance on the same periods as development evidence. Obtain new data or arrange a later test for independent evidence.
Record choices in walk-forward tests too
Each round develops the rule on past data and tests it on a later period. If labels span several days, check for overlap at the boundary and use a gap when the information horizon requires one. Randomly shuffling time-series data can leak related information across the split.
If you look at all walk-forward results to pick a window, those results enter selection. Record the rule version, costs, every attempt, and reasons for changes. Short data may warrant a conclusion of insufficient evidence.
Bias, Overfitting, and Out-of-Sample Testing experiment
Predict how the probability of at least one false positive changes when independent tests increase from 1 to 20. Then decide whether to revise the rule after seeing the final test.
The probability model assumes independence, true nulls, and a 5% false-positive rate per test. The period split illustrates data roles. The five-day teaching data are too short for a statistical out-of-sample test.
Points follow the order in the example. See the table for exact values.
Try the calculations
Use the values in each question. Enter amounts and percentages in the requested units, including a minus sign where needed.
Explain your reasoning
Lesson work
Record every attempt and plan a validation on data that played no role in selection.
Fill out a research experiment log
You develop a strategy in periods 1–6, select a version in 7–8, and first test it in 9–10. You then add a filter based on those test results and rerun the test. In a separate probability exercise, two independent tests have no real effect to detect and each has a 5% false positive rate.
Complete the questions below before trying the optional writing exercise. Use the fixed inputs here, even if you changed the experiment above. Enter numbers in the units shown and keep at least two decimal places where needed. Follow the specified precision for tables. You can check one answer at a time or all answers together.
Save your homework to export these results. Check again after changing an answer. Optional writing and self-assessment are ungraded. Save your work before refreshing.
Optional writing (ungraded)
Writing guidance and self-review
Record the inputs, rules, results and open questions in each field. You can cite the earlier calculations and experiments as fictional examples. Tie each conclusion to specific data or events.
Use the checklist to review your own writing. Use evidence from the study to evaluate the strategy.
Save the experiment, the run log, your first and current checks, written work and self-review. Export before refreshing or closing the page.