[SciPy-User] Request for usage examples on scipy.stats.rv_continuous and scipy.ndimage.grey_dilate(structure)
Robert Kern
robert.kern@gmail....
Mon Mar 22 12:13:56 CDT 2010
On Mon, Mar 22, 2010 at 11:58, Christoph Deil
<Deil.Christoph@googlemail.com> wrote:
> Dear Robert,
>
> thanks for the tip. I tried understanding the examples in scipy/stats/distributions.py, but being a python / scipy newbie I find the mechanism hard to understand and couldn't implement the simple examples I suggested below.
What confused you?
> Maybe it would be possible to add an example to the tutorial? At http://docs.scipy.org/scipy/docs/scipy-docs/tutorial/stats.rst/#stats there is an example on how to use rv_discrete, but none on how to use rv_continuous.
>
> Would it be possible to add a convenience function to scipy.stats that makes it easy to construct a distribution from a function:
>>>> p = lambda x: x**2
>>>> pdist = scipy.stats.rv_continuous_from_function(pdf=p, lim=[0,2]) # a suggestion, doesn't exist at the moment
>>>> samples = pdist.rvs(size=10)
class x2_gen(rv_continuous):
def _pdf(self, x):
return x * x * 0.375
x2 = x2_gen(a=0.0, b=2.0, name='x2')
> I would guess that getting random numbers from a user defined distribution function is such a common usage that it would be nice (at least for newbies like me :-) to being able to do it from the command line, without having to derive a class.
It's not particularly common, no.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list