Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def simulate_under_null(num_chances_to_change):
- """Simulates some number changing several times, with an equal
- chance to increase or decrease. Returns the value of our
- test statistic for these simulated changes.
- num_chances_to_change is the number of times the number changes.
- """
- uniform = Table().with_columns(
- "Change", make_array('Increase', 'Decrease'),
- "Chance", make_array(0.5, 0.5))
- test_statistic = uniform.sample_from_distribution('Chance', num_chances_to_change)
- return abs(test_statistic.column("Chance sample").item(0) - test_statistic.column("Chance sample").item(1))
- uniform_samples = make_array()
- for i in np.arange(5000):
- uniform_samples = np.append(uniform_samples, simulate_under_null(num_changes))
- Table().with_column('Test statistic under null', uniform_samples).hist(0, bins=np.arange(-100, 400+25, 25))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement