Untitled
unknown
plain_text
a year ago
385 B
8
Indexable
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()
```
Editor is loading...
Leave a Comment