What is the fastest way to calculate CDF of T-distribution?

27 views
Skip to first unread message

Paul Royik

unread,
Apr 22, 2015, 7:17:09 AM4/22/15
to sy...@googlegroups.com
I need to calculate P(X<1.2) where X follows T distribution with 5 degrees of freedom.

cdf(StudentT('x',5))(1.2) takes too much time.

Is there another way?

Aaron Meurer

unread,
Apr 22, 2015, 11:38:29 AM4/22/15
to sy...@googlegroups.com
Are you just looking for a numerical answer. The sympy.stats module
tries to do things symbolically, meaning it can choke if it hits a
hard integral.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/d3f9ee62-3b39-40ad-87d1-a4609bb5a7a0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Paul Royik

unread,
Apr 23, 2015, 2:51:18 AM4/23/15
to sy...@googlegroups.com
I'm looking for numerical answer. No need to find analytical solution.

Matthew Brett

unread,
Apr 23, 2015, 1:04:46 PM4/23/15
to sympy
Hi,

On Wed, Apr 22, 2015 at 11:51 PM, Paul Royik <distan...@gmail.com> wrote:
> I'm looking for numerical answer. No need to find analytical solution.
>
> On Wednesday, April 22, 2015 at 6:38:29 PM UTC+3, Aaron Meurer wrote:
>>
>> Are you just looking for a numerical answer. The sympy.stats module
>> tries to do things symbolically, meaning it can choke if it hits a
>> hard integral.
>>
>> Aaron Meurer
>>
>> On Wed, Apr 22, 2015 at 6:17 AM, Paul Royik <distan...@gmail.com> wrote:
>> > I need to calculate P(X<1.2) where X follows T distribution with 5
>> > degrees
>> > of freedom.
>> >
>> > cdf(StudentT('x',5))(1.2) takes too much time.

I think you want scipy for that:

>>> import scipy.stats as sps
>>> sps.t.cdf(1.2, 5)
0.85805447164694892

Best,

Matthew

Paul Royik

unread,
Apr 23, 2015, 1:47:56 PM4/23/15
to sy...@googlegroups.com
Thanks.
Reply all
Reply to author
Forward
0 new messages