On Sat, Mar 14, 2009 at 1:37 PM, <josef.p...@gmail.com> wrote:

> On Sat, Mar 14, 2009 at 3:11 PM, Charles R Harris
> <charlesr.har...@gmail.com> wrote:
> > Hi Josef,
> >
> > On Sat, Mar 14, 2009 at 12:14 PM, <josef.p...@gmail.com> wrote:
> > <snip>
> >
> >>
> >> {{{
> >> import numpy as np
> >>
> >> assert np.all(np.random.hypergeometric(3,18,11,size=10) < 4)
> >> assert np.all(np.random.hypergeometric(18,3,11,size=10) > 0)
> >>
> >> pr = 0.8
> >> N = 100000
> >> rvsn = np.random.logseries(pr,size=N)
> >> # these two frequency counts should be close to theoretical numbers
> >> with this large sample
>
> Sorry, cut and paste error, the second case is k=2
> for k=1 the unpatched version undersamples, for k=2 the unpatched
> version oversamples, that's the reason for the inequalities; the
> bugfix should reallocate them correctly.
>
> for several runs with N = 100000, I get with the patched version
>
> >>> rvsn = np.random.logseries(pr,size=N); np.sum(rvsn==1) / float(N)
> in range:  0.4951, 0.4984    # unpatched version is too small
>
> >>> rvsn = np.random.logseries(pr,size=N); np.sum(rvsn==2) / float(N)
>  in range:  0.1980, 0.2001  # unpatched version is too large
>
> with constraints a bit more tight, it should be:
>
> >> assert np.sum(rvsn==1) / float(N) > 0.49   # theoretical:  0.49706795
> >> assert np.sum(rvsn==2) / float(N) < 0.205   # theoretical:  0.19882718
>

OK. One more question: how often do the tests fail? I want to include a note
to repeat testing if the test fails.

Chuck
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to