Re: Trying to understand Distributions

Paul Hobson <[email protected]> Tue, 13 Jul 2021 10:22:53 -0700
Newsgroups gmane.comp.python.scientific.user
Message-ID <CADT3MEAMxARmOAUo+jQ1W9jxjeuD-fRw1uwDFh2BfKLJQBg77g@mail.gmail.com>
Keith,

Robert's given you great advice. My library (paramnormal) might help you
out here if you're still struggling. It's basically a wrapper around select
scipy distributions to make the parameterization a little more conventional.
http://phobson.github.io/paramnormal/tutorial/fitting.html

The gamma distribution is one of the ones whose wrapper has be implemented
http://phobson.github.io/paramnormal/api/paramnormal.html#paramnormal.dist.gamma

Good luck,
-Paul






On Mon, Jul 12, 2021 at 9:55 PM Robert Kern <[email protected]> wrote:

> x = np.linspace(x0, x1, 100)
>
> On Tue, Jul 13, 2021 at 12:46 AM Keith Sloan <[email protected]>
> wrote:
>
>> Thanks for all your help, but still not getting it right
>>
>> ax4 = fig.add_subplot(4, 1, 4)
>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data)
>> print(ag2, bg2, cg2)
>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2)
>> #x = np.linspace(stats.gamma.ppf(x0,x1), int(ag2))
>> x = np.linspace(stats.gamma.ppf(x0,x1), 100)
>> ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5,
>> alpha=0.6, label='gamma pdf')
>>
>> plt.show()
>> [image: blank]
>>
>>
>>
>>
>> On 13/07/2021 05:34, Robert Kern wrote:
>>
>> Sorry, please reply, but to the mailing list, not just me personally. The
>> mailing list is set up so that most mail software will default to replying
>> to the mailing list.
>>
>> Don't use `int(ag2)` for the number of steps in the linspace(). It's
>> probably not a suitable value. Try 100.
>>
>> On Tue, Jul 13, 2021 at 12:30 AM Keith Sloan <[email protected]>
>> wrote:
>>
>>> Still doing something wrong
>>>
>>> ax4 = fig.add_subplot(4, 1, 4)
>>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data)
>>> print(ag2, bg2, cg2)
>>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc = bg2, scale=cg2)
>>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2)))
>>> ax4.plot(x, stats.gamma.pdf(x, ag2, loc= bg2, scale = cg2),'r-', lw=5,
>>> alpha=0.6, label='gamma pdf')
>>>
>>> plt.show()
>>> [image: blank]
>>> On 13/07/2021 05:23, Robert Kern wrote:
>>>
>>> Please try to respond to these messages so that the email thread remains
>>> intact. You are making a new thread with each email, which makes the
>>> discussion difficult to follow. It would help me refer back to what we've
>>> gone over previously.
>>>
>>> On Tue, Jul 13, 2021 at 12:16 AM Keith Sloan <[email protected]>
>>> wrote:
>>>
>>>> Again another unsuccessful attempt trying to follow Roberts advice
>>>>
>>>> Data is astronomic so loc = 0 is not okay
>>>>
>>> Okay, then don't omit it.
>>>
>>>> ax4 = fig.add_subplot(4, 1, 4)
>>>>
>>>> ag2, bg2, cg2 =stats.gamma.fit(RErange1[xfield].data)
>>>> print(ag2, bg2, cg2)
>>>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, scale=cg2)
>>>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2)))
>>>> ax4.plot(x, stats.gamma.pdf(x, ag2, scale = cg2),'r-', lw=5, alpha=0.6,
>>>> label='gamma pdf')
>>>>
>>> x0, x1 = stats.gamma.ppf([0.1, 0.99], ag2, loc=bg2, scale=cg2)
>>> x = np.linspace(stats.gamma.ppf(x0,x1, int(ag2)))
>>> ax4.plot(x, stats.gamma.pdf(x, ag2, loc=bg2, scale = cg2),'r-', lw=5,
>>> alpha=0.6, label='gamma pdf')
>>>
>>> --
>>> Robert Kern
>>>
>>> _______________________________________________
>>> SciPy-User mailing [email protected]://mail.python.org/mailman/listinfo/scipy-user
>>>
>>> --
>>> ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/
>>>
>>>
>>
>> --
>> Robert Kern
>>
>> --
>> ========== Art & Ceramics ===========https://www.instagram.com/ksloan1952/
>>
>> _______________________________________________
>> SciPy-User mailing list
>> [email protected]
>> https://mail.python.org/mailman/listinfo/scipy-user
>>
>
>
> --
> Robert Kern
> _______________________________________________
> SciPy-User mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/scipy-user
>

_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user
CA809761-78AB-4E2A-9CF5-5BEAE0D7110D_4_5005_c.jpeg (image/jpeg, 17.1 KB) - not displayed
1402523F-503F-45CC-AF8D-FBF4B8C9C5BC_4_5005_c.jpeg (image/jpeg, 18 KB) - not displayed