I’m assuming a lot of people in the audience haven’t studied statistics, but because this is Rubyconf, plenty of you know the principles of test-driven-development (TDD). If you haven’t studied statistics before, it follows the same principle as TDD.
In TDD, you demonstrate that your code is correct in two steps. First, assume your code is wrong. Second, try to disprove that assumption. The first step is when you write the test so that it fails. The second step is to change your application code so that the test passes.
In statistics we do the same thing. We first assume the opposite of what we want to prove. If we want to show that a drug treats a disease, we first assume that this drug has no effect. That’s what the placebo group is for. The placebo group is the “red” portion of “red-green refactoring.” The group that’s treated with the drug is (hopefully) the “green” portion of “red-green” factoring.
A statistical test will never PROVE that the drug works, just like a passing test doesn’t PROVE that your code works. Both are tools to give you more confidence.
Let's say I want to write a function that returns the absolute value of a number:
def abs(v)
if v == 2
1
elsif v == 1
1
elsif v == 0
0
elsif v == -1
1
elsif v == -2
2
end
end
And then I wrote my tests in rspec:
describe "abs" do
it "returns 2 when given 2" { expect(abs(2)).to eq(2) }
it "returns 1 when given 1" { expect(abs(1)).to eq(1) }
it "returns 0 when given 0" { expect(abs(0)).to eq(0) }
it "returns 1 when given -1" { expect(abs(-1)).to eq(1) }
it "returns 2 when given -2" { expect(abs(-2)).to eq(2) }
end
So what's wrong with this? You wrote your specs, and you implemented the function to make your specs pass? This is the equivalent of overfitting in statistics.
This is great! I think it stands a very good chance of getting accepted. The trick will be making it digestible to non-statisticians (which I am sure you can do) and making it short enough, IMO.