Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We are going to generate a sample independent and uniformly distributed random v

ID: 3783901 • Letter: W

Question

We are going to generate a sample independent and uniformly distributed random variables. Use Python to generate 1000 independent realizations of an uniform U (0, 1) random variable, we can denote them by U_1, ..., U_1000, the data is stored in a vector named U. Print U. Use Python to compute the sample mean, the sample variance, and plot the histogram of U_1, ..., U_1000, . Print the sample mean and the sample variance, and display the histogram. Briefly explain why you can tell that this histogram corresponds to the one of a uniform distribution, and how you could verify that graphically.

Explanation / Answer

import matplotlib as mpl import numpy as np import matplotlib.pyplot as plt import matplotlib.cbook as cbook def read_datafile(file_name): # the skiprows keyword is for heading, but I don't know if trailing lines # can be specified data = np.loadtxt(file_name, delimiter=',', skiprows=10) return data data = read_datafile('e:dir1datafile.csv') x = ??? y = ??? fig = plt.figure() ax1 = fig.add_subplot(111) ax1.set_title("Mains power stability") ax1.set_xlabel('time') ax1.set_ylabel('Mains voltage') ax1.plot(x,y, c='r', label='the data') leg = ax1.legend() plt.show()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote