Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
microprediction committed Dec 3, 2021
1 parent 714e797 commit 2c2ff0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 11 additions & 5 deletions tests/test_lattice_from_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion winning/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2c2ff0b

Please sign in to comment.