Calculating the mean and variance of continuous distribution

155 Views Asked by At

The main question was "A machine produces 2mm to 12mm usb sticks. Any usb greater than 10mm in size will need to be thrown away."

Part A) Calculate the portion that needs to be thrown away, and I got 1/5 or 20%.

Part B) Simulate 50 memory sticks and draw a histogram. I did this in Java by getting a random number between 2 and 12, 50 times. Here are the results:

Length 2: 4 USBs

Length 3: 4 USBs

Length 4: 7 USBs

Length 5: 4 USBs

Length 6: 5 USBs

Length 7: 7 USBs

Length 8: 6 USBs

Length 9: 5 USBs

Length 10: 4 USBs

Length 11:2 USBs

Length 12: 2 USBs

Part C) Calculate the mean and variance. This is where I'm stuck because I don't know how to compute that from what I've found so far.

1

There are 1 best solutions below

0
On

If you are supposed to simulate $n = 50$ observations from a continuous uniform distribution on the interval $(2, 12),$ then make a histogram of the 50 observations and find their mean and variance, then you could do it it R statistical software as follows:

 x = runif(50, 2, 12)
 round(x, 2)  # round to two places for a compact printout

 ##  8.22 11.47 11.29  8.81  7.79  5.39  5.50 11.30 11.84  6.99     
 ##  4.45 11.29  7.76 10.92  9.83 11.78 11.03 10.96  6.63  3.51
 ##  4.13  3.07 11.70  3.37  2.12 10.78  2.38  7.38  9.65 11.58
 ##  3.42 11.18 11.83  2.08  6.90  2.30 11.72 11.06  6.33  7.21
 ##  2.50  5.18  9.53  6.34  8.53  2.94  7.62  4.18  7.11  9.73
 mean(x);  var(x)
 ## 7.61225
 ## 10.99174

 hist(x)  # frequency histogram
 rug(x)   # small tick marks show location of each simulated value

enter image description here

But this is a $random$ experiment, so you will get different results every time you do it. For example, here are the mean and variance from my second try:

 x2 = runif(50, 2, 12)
 mean(x2); var(x2)
 ## 6.785483
 ## 8.911308