Skip to content

Commit

Permalink
Merge pull request #67 from better/fix-rws
Browse files Browse the repository at this point in the history
Fix RVS
  • Loading branch information
erikbern committed Aug 21, 2018
2 parents 96c49a7 + ad1cbed commit a88a6be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions convoys/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ def rvs(self, x, n_curves=1, n_samples=1, T=None):
adjusted_z = cdf_now + (1 - cdf_now) * z
B[i] = (adjusted_z < c)
y = adjusted_z / c
x = gammaincinv(k, y)
w = gammaincinv(k, y)
# x = (t * lambd)**p
C[i] = x**(1./p) / lambd
C[i] = w**(1./p) / lambd
C[i][~B[i]] = 0

return B, C
Expand Down
2 changes: 1 addition & 1 deletion test_convoys.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_exponential_regression_model(c=0.3, lambd=0.1, n=10000):
assert 0.80*c < y < 1.30*c

# Check the random variates
will_convert, convert_at = model.rvs([1], n_curves=1, n_samples=10000)
will_convert, convert_at = model.rvs([1], n_curves=10000, n_samples=1)
assert 0.80*c < numpy.mean(will_convert) < 1.30*c
convert_times = convert_at[will_convert]
for t in [1, 3, 10]:
Expand Down

0 comments on commit a88a6be

Please sign in to comment.