[SciPy-User] Rician distributions lacks sigma parameter
Wed Apr 4 06:51:42 CDT 2012
On Wed, Apr 4, 2012 at 7:30 AM, <firstname.lastname@example.org> wrote:
> On Wed, Apr 4, 2012 at 3:00 AM, Morten Kjeldgaard <email@example.com> wrote:
>> I am a new reader of this list, please forgive me if this issue has
>> already discussed.
>> I have been wanting to use the rician distribution (stats.rice) to
>> analyze some data, but it seems that the implementation in scipy does
>> not take the distribution's sigma parameter into account; rather, it
>> has been set to 1.0. The wikipedia article shows the traditional
>> formulation of the rician distribution .
>> I understand that some distributions, e.g. stats.norm, use the scale
>> parameter to define std, but this does not seem to be the case with
>> Any ideas on how to get around this, without actually modifying
>> distribution.py? I have no experience with the internals of scipy, and
>> wouldn't know how to modify it correctly.
>>  http://en.wikipedia.org/wiki/Rice_distribution
> location loc and scale are handled generically for all distribution.
> you can add loc=some number and scale= some number to almost all
> methods of the distributions. This replaces x by (x-loc)/scale in the
> calculation in the function, e.g. the _pdf, (the pdf gets an
> additional 1/scale in front for the transformation)
> For example:
> from scipy import stats
>>>> x = np.linspace(0, 10, 100)
>>>> import matplotlib.pyplot as plt
>>>> for s in [0.5, 1, 2, 5, 10]: plt.plot(x, stats.rice.pdf(x, 0.5 , scale=s))
> [<matplotlib.lines.Line2D object at 0x04EB8170>]
> [<matplotlib.lines.Line2D object at 0x04EB8470>]
> [<matplotlib.lines.Line2D object at 0x04EB8790>]
> [<matplotlib.lines.Line2D object at 0x04EB8AB0>]
> [<matplotlib.lines.Line2D object at 0x04EB8DD0>]
> However, I don't see how the rice_gen._pdf matches up with the formula
> on the Wikipedia page.
> It looks to me that it uses a different parameterization for the shape
> parameter v. (Or I didn't have enough coffee yet)
> bugs in this case (only _pdf is defined) could be possible, because
> the tests only check for consistency across methods, but in most cases
> the distributions are not externally verified.
(after another coffee)
the shape parameter in stats.rice corresponds to (v/sigma) in the
Wikipedia page. This is a consequence of the generic treatment of
location and scale.
>> SciPy-User mailing list
More information about the SciPy-User