[SciPy-User] Request for usage examples on scipy.stats.rv_continuous and scipy.ndimage.grey_dilate(structure)
Christoph Deil
Deil.Christoph@googlemail....
Mon Mar 22 12:47:42 CDT 2010
On Mar 22, 2010, at 6:13 PM, Robert Kern wrote:
> 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?
I didn't know how to specify the limits. The rv_continuous docstring says:
Constructor information:
Definition: scipy.stats.rv_continuous(self, momtype=1, a=None, b=None, xa=-10.0, xb=10.0, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None)
The meaning of the parameters a, b, xa, xb doesn't seem to be documented. Now that I had a look at the source code it's obvious.
>
>> 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')
Thanks! This works.
Multidimensional correlated parameter distributions like pdf(x,y) = x*y cannot be implemented using rv_continuous, right?
If yes, is there a python module to work with correlated multidimensional pdfs?
>
>> 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
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list