Untitled

 avatar
unknown
plain_text
a year ago
795 B
5
Indexable
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats

# Degrees of freedom
df = 41

# Calculated t-statistic
t_statistic = 2.53

# Generate x values for the t-distribution
x = np.linspace(-4, 4, 1000)

# Calculate y values (probability density) for the t-distribution
y = stats.t.pdf(x, df)

# Create the plot
plt.plot(x, y, 'b-', label='t-Distribution')

# Shade the area to the right of the t-statistic
plt.fill_between(x, 0, y, where=(x > t_statistic), color='orange', alpha=0.5, label='p-value Area')

# Mark the t-statistic
plt.axvline(x=t_statistic, color='r', linestyle='--', label='t-statistic')

# Add labels and legend
plt.xlabel('t-values')
plt.ylabel('Probability Density')
plt.title('t-Distribution with p-value Area')
plt.legend()

# Show plot
plt.show()
Editor is loading...
Leave a Comment