Simulate 3000 times the value of \(X\), draw the histogram
with 50 columns, draw the two density functions, and then
decide which of them may be a density function of \(X\).
Write out the result with a single letter (a
or b
)
on the terminal.
party.py
. The output is a figure and a single letter on the terminal.
On the figure there are
two graphs of functions defined on \([0,1]\) and a histogram of
50 columns in the same window.import numpy as np import matplotlib.pyplot as plt # t will be a list with elements 0, .02, .04,..., 1 t = np.linspace(0, 1, 51) plt.plot(t, dfunc(t), color = "red")Here the first argument of the function plot is the list of the values of the domain, and the second argument contains the values of the function at these points, where dfunc have to be defined before.
plt.hist(experiments, bins=t, density=1)