question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

incorrect first moment of non central t-distribution

See original GitHub issue

My issue is about the calculation of the first moment in t-distribution, which is wrong. I’m following the tutorial example from https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.t.html. By directly implementing the formula from wikipedia (https://en.wikipedia.org/wiki/Noncentral_t-distribution) I get a different result than through the scipy package. It seems that the first moment is always equal to the specified location (loc parameter).

Reproducing code example:

import numpy as np
from scipy.stats import t
from scipy.special import gamma

df = 10
loc = 1

scipy_first_moment = t.stats(df = df, loc = loc, moments='m')
real_first_moment = loc*np.sqrt(df/2)*(gamma(0.5*(df-1))/gamma(df/2))

print(scipy_first_moment == real_first_moment)

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  ...

Scipy/Numpy/Python version information:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rlucas7commented, May 16, 2020

I agree w/ @josef-pkt If it starts to come up more frequently we can always revisit.

0reactions
josef-pktcommented, May 15, 2020

note in the docstring, We cannot identify when a user doesn’t interpret the parameters correctly.

(twice in a row in 11 years is not a whole lot)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Noncentral t-distribution
The noncentral t-distribution generalizes Student's t-distribution using a noncentrality ... distribution describes how t is distributed when the null is false.
Read more >
Noncentral t Distribution
Describes the Noncentral t Distribution and how to calculate the cumulative distribution (cdf) and probability distribution (pdf) function values in Excel.
Read more >
A Study of non-central Skew t Distributions and their ...
PROBLEM UNDER THE NON-CENTRAL SKEW t DISTRIBUTION 75 ... The moment generating function and the first few moments of the skew normal distribution....
Read more >
statistics - Why is noncentral t-distribution for sample size ...
This is wrong because s itself is a random variable and therefore cannot be included in the bounds. If it were, I could...
Read more >
Non-central t distribution and the power of the t test
ties in with the non-central t distribution, explicitly noted ... f (t) = (2) in which . (2). Its first statistical moments are:....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found