Fix Jiffle sdev() returning the range instead of the standard deviation - #314
Open
james-willis wants to merge 1 commit into
Open
Fix Jiffle sdev() returning the range instead of the standard deviation#314james-willis wants to merge 1 commit into
james-willis wants to merge 1 commit into
Conversation
JiffleFunctions.sdev called SampleStats.range rather than SampleStats.sdev, so the Jiffle sdev() function returned the range of its input list. Fix the delegation and add tests: one asserting the sample standard deviation of a known list, one asserting sdev(z)^2 == variance(z).
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.
Bug
JiffleFunctions.sdevdelegates toSampleStats.rangeinstead ofSampleStats.sdev:so the Jiffle
sdev()script function actually returns the range of its input list, e.g.sdev([1, 2, 3, 4])returns3.0instead ofsqrt(5/3) ≈ 1.29099.variance()is unaffected (it correctly delegates toSampleStats.variance).Fix
One-line delegation fix, plus two new tests in
StatsFunctionsTest:sdevListArgasserts the sample standard deviation of a fixed list, andsdevIsSquareRootOfVarianceassertssdev(z)*sdev(z) == variance(z)per pixel.mvn -pl jt-jiffle/jt-jiffle-language testpasses (291 tests) under JDK 8.Compatibility note
Any script relying on the buggy behavior will see different results after this fix;
range()remains available for callers who actually want the range.