[SciPy-User] Rician distributions lacks sigma parameter

josef.pktd@gmai... josef.pktd@gmai...
Wed Apr 4 15:57:28 CDT 2012


On Wed, Apr 4, 2012 at 1:59 PM,  <josef.pktd@gmail.com> wrote:
> On Wed, Apr 4, 2012 at 1:53 PM,  <josef.pktd@gmail.com> wrote:
>> On Wed, Apr 4, 2012 at 1:33 PM, Morten Kjeldgaard <mok@bioxray.dk> wrote:
>>> Thanks for replies Josef and Warren!
>>>
>>> I think my current limitation is that I don't fully grasp how the
>>> shape and scale parameters are propagated to the individual stats
>>> distributions, and alas the autogenerated documentation isn't always
>>> very helpful.
>>>
>>>> Given the parameters nu and sigma (as shown in the wikipedia
>>>> article), you use scipy.stats.rice by setting the scale=sigma and
>>>> the shape parameter b=nu/sigma.  You can use the following script to
>>>> verify this:
>>>
>>> Like you write, the script works fine with parameters (nu, sigma) =
>>> (3.45, 0.35), but it actually fails when I try to reproduce the plots
>>> in the wikipedia article. When setting (nu, sigma) = (0, 1), I get the
>>> following:
>>
>> the shape parameter nu has to be strictly positive, eg. nu=1e-10 works
>> there is a problem with the calculation for nu equal to zero
>
> But the _pdf doesn't have a problem
>>>> stats.rice._pdf(np.linspace(0,4,11),0.)
> array([ 0.        ,  0.36924654,  0.58091923,  0.58410271,  0.44485968,
>        0.27067057,  0.13472343,  0.05555507,  0.01912327,  0.00552172,
>        0.00134185])
>
>>>> stats.rice.pdf(np.linspace(0,4,11),0.)
> array([ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan])
>>>>
>
> so it should be possible to fix it for the nu=0 case, (define a>= 0 ?)

should be a ticket: define _argcheck for rice

something like the following (but I didn't check which args _argcheck
is supposed to have)

>>> def _argcheck(self, *args): return args >=0
...
>>> stats.rice._argcheck = _argcheck
>>> stats.rice.pdf(np.linspace(0,4,11),0.)
array([ 0.        ,  0.36924654,  0.58091923,  0.58410271,  0.44485968,
        0.27067057,  0.13472343,  0.05555507,  0.01912327,  0.00552172,
        0.00134185])
>>> stats.rice._pdf(np.linspace(0,4,11),0.)
array([ 0.        ,  0.36924654,  0.58091923,  0.58410271,  0.44485968,
        0.27067057,  0.13472343,  0.05555507,  0.01912327,  0.00552172,
        0.00134185])

Josef


>
> Josef
>
>
>>
>> Josef
>>
>>>
>>> AssertionError:
>>> Not equal to tolerance rtol=1e-07, atol=0
>>>
>>> x and y nan location mismatch:
>>>  x: array([  0.00000000e+00,   3.99680128e-02,   7.97444092e-02,
>>>          1.19139103e-01,   1.57965051e-01,   1.96039735e-01,
>>>          2.33186584e-01,   2.69236346e-01,   3.04028363e-01,...
>>>  y: array([ nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,
>>> nan,  nan,
>>>         nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,
>>> nan,
>>>         nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,  nan,
>>> nan,...
>>>
>>> In other words, your defined function rice_pdf works, but stats.rice
>>> does not.
>>>
>>> Cheers,
>>> Morten
>>>
>>> _______________________________________________
>>> SciPy-User mailing list
>>> SciPy-User@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-User mailing list