File:T distribution 1df enhanced.svg
Summary
| Description |
English: Comparison between Normal distribution and Student's t-distribution. It will be used in the article 'Student's t-distribution'. Enhanced plotting. |
| Date | |
| Source | Own work |
| Author | IkamusumeFan |
| SVG development | |
| Source code | Python codeimport numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp
X = np.arange(-4, 4, 0.01) # range of the graph
plt.clf()
plt.figure(figsize=(4,4))
plt.axes([0.17,0.13,0.79,0.8])
plt.hold(True)
Q = [] # No curves at first.
# Draw the curve of Normal distribution
k = 0 # choose blue
mu = 0 # mean = 0
sigma = 1 # variance = 1
A = 1/(sigma*np.sqrt(2*np.pi))
B = np.exp(-(X-mu)*(X-mu)/(2*sigma*sigma));
Y = A*B
a = plt.plot(X, Y, '-', color='blue', lw=2)
Q.append(a)
# Draw the curve of Student's t-distribution
k = 1 # choose red
mu = 0 # mean = 0
nu = 1 # freedom degree = 1
A = np.exp(sp.gammaln((nu+1)/2.0));
B = np.exp(sp.gammaln(nu/2.0))*np.sqrt(nu*np.pi);
C = (1+X*X/nu)**(-(nu+1)/2.0);
Y = A*C/B;
a = plt.plot(X, Y, '-', color='red', lw=2)
Q.append(a)
# Remaining steps to finish drawing the graph.
plt.xlabel("x")
plt.ylabel("P(x)")
plt.xlim(-4,4)
# Saving the output.
plt.savefig("T_distribution_1df.pdf")
plt.savefig("T_distribution_1df.eps")
plt.savefig("T_distribution_1df.svg")
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 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.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.