In a Student’s t-test, the test statistic follows the t-distribution graph. The Student’s t-distribution graph is symmetric and bell-shaped. The shape of the curve depends on the degrees of freedom. The t-distribution graph tends to be similar to the standard normal distribution graph when the degrees of freedom tends to be infinity.
We can use the following Python code to generate the t-distribution graph for specific degrees of freedom.
import numpy
from scipy.stats import t
from matplotlib import pyplot
X = numpy.linspace(-4, 4, 200)
# Generate t-distribution graph for a specific degrees of freedom
Y = t.pdf(X, df=19)
pyplot.plot(X, Y)
pyplot.savefig("t-dist-graph-19.png")
pyplot.close()
Here, we are using the numpy linspace() function to generate 200 points on the x-axis within the range –4 to 4. After that, we are using the t.pdf() function to generate the points on the y-axis corresponding to the points on the x-axis.
Finally, we are using the pyplot Python module to plot the graph. Here, we are generating the t-distribution graph for 19 degrees of freedom. The generated graph will like the following: …








































0 Comments