[SciPy-User] Rician distributions lacks sigma parameter
josef.pktd@gmai...
josef.pktd@gmai...
Wed Apr 4 06:51:42 CDT 2012
On Wed, Apr 4, 2012 at 7:30 AM, <josef.pktd@gmail.com> wrote:
> On Wed, Apr 4, 2012 at 3:00 AM, Morten Kjeldgaard <mok@bioxray.dk> wrote:
>> Hi,
>>
>> 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 [0].
>>
>> 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
>> stats.rice.
>>
>> 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.
>>
>> Cheers,
>> Morten
>>
>> [0] 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>]
>>>> plt.show()
>
> 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.
Josef
>
> Josef
>
>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
More information about the SciPy-User
mailing list