Untitled

mail@pastecode.io avatar
unknown
plain_text
18 days ago
385 B
1
Indexable
Never
import matplotlib.pyplot as plt

# Data
X = [0, 1, 2, 3, 4]
P_X = [0.17, 0.34, 0.24, 0.20, 0.05]

# Create histogram
plt.bar(X, P_X, width=0.4, color='blue', alpha=0.7)

# Adding titles and labels
plt.title('Histogram of Probability Distribution')
plt.xlabel('X values')
plt.ylabel('Probability P(X)')
plt.xticks(X)  # Set x-ticks to be the values of X

# Show the plot
plt.show()
```
Leave a Comment