diff --git a/setup.py b/setup.py index 10257a2..0dfa4b7 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name="winning", - version="0.4.5", + version="0.4.6", description="Fast algorithm inferring relative ability from contest winning probabilities", long_description=README, long_description_content_type="text/markdown", diff --git a/tests/test_lattice_from_samples.py b/tests/test_lattice_from_samples.py index b02ea19..3499d6d 100644 --- a/tests/test_lattice_from_samples.py +++ b/tests/test_lattice_from_samples.py @@ -9,14 +9,20 @@ def test_samples(): mu = mean_of_density(density=d,unit=unit) +def test_die(): + x = [ np.random.choice([-2.5,-1.5,-0.5,0, 0.5,1.5,2.5]) for _ in range(10000) ] + unit = 1 + d = density_from_samples(x=x,L=5, unit=0.5) + mu = mean_of_density(density=d,unit=unit) + print(mu) + return d + + if __name__=='__main__': - x = np.random.randn(5000) - unit = 0.05 - d = density_from_samples(x=x, L=501, unit=unit) - mu = mean_of_density(density=d, unit=unit) - print(mu / unit) + d = test_die() import matplotlib.pyplot as plt + print(d) plt.plot(d) plt.show() \ No newline at end of file diff --git a/winning/lattice.py b/winning/lattice.py index 5bd9d29..e279e7e 100644 --- a/winning/lattice.py +++ b/winning/lattice.py @@ -57,7 +57,7 @@ def density_from_samples(x: [float], L: int, unit=1.0): mass = 0 for lh in low_highs: for (lc, wght) in lh: - rel_loc = min(2 * L - 1, max(lc + L, 0)) + rel_loc = min(2 * L, max(lc + L, 0)) mass += wght density[rel_loc] += wght total_mass = sum(density)