Repository navigation
Add the "No median feat" exercise - #17
Merged
Merged
Conversation
Starter code, tests and notebook for trimmed means, MAD, outlier flagging and Theil-Sen regression, with simulation to measure breakdown and efficiency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the notebook's contaminate function with glitch, which chooses the glitch size, direction and position and accepts a seeded generator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Theil-Sen is more precise than least squares under skewed noise, and the 29% breakdown point is a worst case: random glitches do far less harm. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simulate yields noisy straight-line datasets with normal or skewed noise and optional glitches, so the notebook's Monte Carlo loops need no boilerplate. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
sample yields one-dimensional samples (normal, exponential or t, with optional glitches) so section 2 can compare estimators across kinds of data. simulate shares the noise options. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d exercises The module now holds glitch, sample and simulate. A likely story, Known unknowns and the root README point to the new exercise. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the skewed-noise intercept question into section 4, where the data already are, and compare only glitches at the start with glitches at random positions. The other glitch options become an extension. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds No median feat (🌶️🌶️), a robust-estimation exercise in Uncertainty and Simulation, on simulated data so the truth is always known.
The exercise
Three stages, building from the median to a regression line that is hard to fool:
trimmed_mean. Learners find breakdown points by glitching data, then compare bias and standard error across normal, skewed, heavy-tailed and glitched samples.madandflag_outliers, showing why the 3σ rule cannot flag anything in a sample of ten.theil_sen, compared with least squares under clean, glitched and skewed noise, and where its breakdown point really is.The learner functions are unfinished stubs, as in other exercises. Their 13 tests fail until implemented.
Supplied helpers
exercises/no_median_feat/simulation.pyprovidesglitch,sampleandsimulate, so the notebook is not full of Monte Carlo boilerplate. They share one set of noise options (normal,exponential,t, all with the same mean and standard deviation) and accept a seededrng. They have their own tests intests/test_no_median_feat_simulation.py, which pass.Also changed
README.mdand aNEWS.mdline.no_median_featadded toREQUIRED_NOTEBOOKSintests/test_notebooks.py.Checks
ruff check,ruff format --check,pytest --collect-onlyandpytest tests -qall pass.Merge order
The reference solution is in the private solutions repo. That PR verifies against this repo's
main, so merge this one first and then re-run it.README.mdto the new exercise.