MATLAB statistics with uniform distribution

121 Views Asked by At

I have created a random uniform distribution with values between $5$ and $6.5$. I have also found the mean. I am stuck on a problem that asks how many values are higher than the mean.

How would I do this? I've tried the length(find(x)) function but it did not work. help please?

   pd=makedist('Uniform','Lower',5,'Upper',6.5)
   average_height=mean(pd) 
   length(find(pd>5.75))`
1

There are 1 best solutions below

0
On

I don't see that you have specified how many observations you have chosen at random from $Unif(5, 6.5).$ So it is not clear what you are trying to do or what you are asking.

This is a symmetrical distribution with mean and median 5.75. About half of your observations should exceed 5.75.

With m = 10^6 observations, we have the following simulation in R.

 m  = 10^6;  x = runif(m, 5, 6.5)
 mean(x);  median(x)
 ## 5.750394
 ## 5.749982
 sum(x > 5.75)
 ## 499985

The vector x > 5.75 is logical, having element TRUE for values of x greater than 5.75, and FALSE otherwise. The sum of a logical vector treats each TRUE as a 1 and each FALSE as a 0. Thus the last statement provides a count of the observations exceeding 5.75.