negsquarenormalg.pdf(nxx, loc=l, scale=s)) print('\nsquare of a t distributed random variable with dof=10 is') print(' F with dof=1,10 distributed') print('sqt cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.cdf(xx, 10)) print('sqt 1-sf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), 1 - squaretg.sf(xx, 10)) print('f cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.cdf(xx, 1, 10)) print('sqt pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.pdf(xx, 10)) print('f pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.pdf(xx, 1, 10)) print('sqt ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), squaretg.ppf(ppfq, 10)) print('f ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), stats.f.ppf(ppfq, 1, 10)) print('sqt cdf for 100:', squaretg.cdf(100, 10)) print('f cdf for 100:', stats.f.cdf(100, 1, 10)) print('sqt stats:', squaretg.stats(10, moments='mvsk')) print('f stats:', stats.f.stats(1, 10, moments='mvsk')) #Note the results differ for skew and kurtosis. I think the 3rd and 4th moment # in the scipy.stats.f distribution is incorrect. # I corrected it now in stats.distributions.py in bzr branch v1 = 1 v2 = 10 g1 = 2 * (v2 + 2 * v1 - 2.) / (v2 - 6.) * np.sqrt(2 * (v2 - 4.) / (v1 * (v2 + v1 - 2.))) g2 = 3 / (2. * v2 - 16) * (8 + g1 * g1 * (v2 - 6.)) print('corrected skew, kurtosis of f(1,10) is', g1, g2)
print('nsqnorm 1-sf for (%3.2f, %3.2f, %3.2f):' % tuple(nxx), 1-negsquarenormalg.sf(nxx,loc=l, scale=s)) print('chi2 sf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.chi2.sf(xx,1)) print('nsqnorm pdf for (%3.2f, %3.2f, %3.2f):' % tuple(nxx), negsquarenormalg.pdf(nxx,loc=l, scale=s)) print('chi2 pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.chi2.pdf(xx,1)) print('nsqnorm pdf for (%3.2f, %3.2f, %3.2f):' % tuple(nxx), negsquarenormalg.pdf(nxx,loc=l, scale=s)) print('\nsquare of a t distributed random variable with dof=10 is') print(' F with dof=1,10 distributed') print('sqt cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.cdf(xx,10)) print('sqt 1-sf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), 1-squaretg.sf(xx,10)) print('f cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.cdf(xx,1,10)) print('sqt pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.pdf(xx,10)) print('f pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.pdf(xx,1,10)) print('sqt ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), squaretg.ppf(ppfq,10)) print('f ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), stats.f.ppf(ppfq,1,10)) print('sqt cdf for 100:', squaretg.cdf(100,10)) print('f cdf for 100:', stats.f.cdf(100,1,10)) print('sqt stats:', squaretg.stats(10, moments='mvsk')) print('f stats:', stats.f.stats(1,10, moments='mvsk')) #Note the results differ for skew and kurtosis. I think the 3rd and 4th moment # in the scipy.stats.f distribution is incorrect. # I corrected it now in stats.distributions.py in bzr branch v1=1 v2=10 g1 = 2*(v2+2*v1-2.)/(v2-6.)*np.sqrt(2*(v2-4.)/(v1*(v2+v1-2.))) g2 = 3/(2.*v2-16)*(8+g1*g1*(v2-6.)) print('corrected skew, kurtosis of f(1,10) is', g1, g2) print(squarenormalg.rvs()) print(squarenormalg.rvs(size=(2,4)))
print 'nsqnorm pdf for (%3.2f, %3.2f, %3.2f):' % tuple( nxx), negsquarenormalg.pdf(nxx, loc=l, scale=s) print '\nsquare of a t distributed random variable with dof=10 is' print ' F with dof=1,10 distributed' print 'sqt cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.cdf( xx, 10) print 'sqt 1-sf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), 1 - squaretg.sf( xx, 10) print 'f cdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.cdf( xx, 1, 10) print 'sqt pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), squaretg.pdf( xx, 10) print 'f pdf for (%3.2f, %3.2f, %3.2f):' % tuple(xx), stats.f.pdf( xx, 1, 10) print 'sqt ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), squaretg.ppf( ppfq, 10) print 'f ppf for (%3.2f, %3.2f, %3.2f):' % tuple(ppfq), stats.f.ppf( ppfq, 1, 10) print 'sqt cdf for 100:', squaretg.cdf(100, 10) print 'f cdf for 100:', stats.f.cdf(100, 1, 10) print 'sqt stats:', squaretg.stats(10, moments='mvsk') print 'f stats:', stats.f.stats(1, 10, moments='mvsk') #Note the results differ for skew and kurtosis. I think the 3rd and 4th moment # in the scipy.stats.f distribution is incorrect. # I corrected it now in stats.distributions.py in bzr branch v1 = 1 v2 = 10 g1 = 2 * (v2 + 2 * v1 - 2.) / (v2 - 6.) * np.sqrt(2 * (v2 - 4.) / (v1 * (v2 + v1 - 2.))) g2 = 3 / (2. * v2 - 16) * (8 + g1 * g1 * (v2 - 6.)) print 'corrected skew, kurtosis of f(1,10) is', g1, g2