MATH 314 Homework 02

Due 2025-09-10 by 11:59pm

  1. Write a function that calculates the density function for the Bernoulli (family of) distributions.

    The function signature should take in one positional argument, x and one keyword argument p. The keyword argument p should default to .

  2. Create a numpy array of less than 10 zeros and ones. You might randomly generate this array using numpy.random.Generator.binomial, with n=1. Or you could just create an array from a list of s and s using np.array(list).

    Evaluate your function on this array, putting the entire array into the argument x.

  3. Plot the density function for the Bernoulli (family of) distributions. Use at least different values for p, but no more than . Color the points associated with each value of p a different color. Label the points associated with each value of p and put a legend on your plot. Put meaningful axis labels on your plot.

  4. Plot the density function for the Uniform (family of) distributions. Use at least different values for (a,b) pairs, but no more than . Color the points associated with each pair of (a,b) a different color. Label the points associated with each pair of (a,b) and put a legend on your plot. Put meaningful axis labels on your plot.