[SciPy-dev] Object array comparisons, Monte Carlo package
Ed Schofield
schofield at ftw.at
Mon Jan 16 04:20:34 CST 2006
Hi Travis,
I'm finding object arrays useful with the new syntax. +1 from me :)
I have a feature request. Object arrays currently don't support rich
(elementwise) comparisons:
>>> d = {'a':10,'b':20,'c':30}
>>> s = montecarlo.dictsampler(d)
>>> s.sample(10000)
array([c, c, b, ..., c, c, b], dtype=object)
>>> s == 'b'
False
Could we enable this again? This would be useful. I seem to recall
that you disabled this a couple of months ago in response to some
problem or other, but I haven't been able to find the thread. If the
problem was with arrays as truth values, is this resolved now?
The first three commands above are an example of using the new Monte
Carlo package to sample from a discrete distribution given a probability
mass function (here unnormalized). It uses Marsaglia's compressed table
lookup sampler, and generates about 50 million variates per second on my
P4, independent of the size of the sample space. It should be useful as
an efficient foundation for various discrete Monte Carlo algorithms.
-- Ed
More information about the Scipy-dev
mailing list