File:Nc student t pdf.svg

Summary

Description
English: Graphs of the probability density functions for several members of the noncentral Student-t family.
Date
Source Own work
Author Skbkekas
SVG development
InfoField
Source code
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp

col = ['orange', 'purple', 'deepskyblue', 'mediumseagreen']

X = np.arange(-5, 10, 0.01)

##                                                                              
## PDF                                                                          
##                                                                              

plt.clf()
plt.figure(figsize=(4,3.2))
plt.axes([0.17,0.13,0.79,0.8])
plt.hold(True)

Q = []
for k,(mu,df) in enumerate([(0.,1.),(0.,4.),(2.,1.),(2.,4.)]):
    Y = df/2*np.log(df) + sp.gammaln(df+1) - df*np.log(2) - mu**2/2
    Y -= (df/2)*np.log(df+X**2)
    Y -= sp.gammaln(df/2)

    A = sp.hyp1f1(df/2+1, 1.5, mu**2*X**2/(2*(df+X**2)))
    B = sp.hyp1f1((df+1)/2, 0.5, mu**2*X**2/(2*(df+X**2)))

    C = np.sqrt(2)*mu*X*A
    C /= df+X**2
    C /= np.exp(sp.gammaln((df+1)/2))

    D = B/np.sqrt(df+X**2)
    D /= np.exp(sp.gammaln(df/2+1))

    Y += np.log(C+D)

    a = plt.plot(X, np.exp(Y), '-', color=col[k], lw=2)
    Q.append(a)

plt.xlabel("x")
plt.ylabel("P(x)")
bx = plt.legend(Q, (r"$\mu=0,\,\nu=1$", r"$\mu=0,\,\nu=4$",\
                    r"$\mu=2,\,\nu=1$", r"$\mu=2,\,\nu=4$"),\
                numpoints=1, handlelen=0.05, handletextpad=0.4,\
                loc="upper right")
bx.draw_frame(False)
plt.xlim(-5,10)

plt.savefig("nc_student_t_pdf.pdf")
plt.savefig("nc_student_t_pdf.svg")
Category:Probability distributions

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 3.0 Unported license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
Category:CC-BY-3.0#Nc%20student%20t%20pdf.svgCategory:Self-published work
Category:CC-BY-3.0 Category:Probability distributions Category:Self-published work Category:Valid SVG created with Matplotlib code