0
$\begingroup$

I have the following assignment:

It requires to generate samples from $u(7,10)$,the uniform distribution on the interval $2 \leq x \leq 11$. Compare the normalized histogram with the density function(pdf).

I have no idea. I need help please, thanks.

  • 0
    This is my early beginning on the study of simulation and I have to work on it,I beg help!2012-06-07
  • 0
    What software can you use? Since we here have no ideas about that, why not ask the person giving the assignement for some help?2012-06-07
  • 0
    It requires us to use MAT LAB.I find it hard to use.2012-06-07
  • 0
    Yet another reason to talk in person to they one making the assignment!2012-06-07

1 Answers 1

1

I don't see why the uniform distribution on $[2,11]$ is denoted by $u(7,10)$, but anyway, the steps are:

  1. Generate a long random vector with uniform distribution on $[0,1]$: for example, rand(1000,1) creates a column vector of size $1000$ with this distribution.
  2. Apply the linear transformation that maps $[0,1]$ onto $[2,11]$
  3. Create the histogram with some reasonable number of bins, maybe $30$.
  4. Plot the constant function $\dfrac{1}{11-2}$ on the interval $[2,11]$: this is the pdf.

The result should look like this:

histogram

I used Scilab instead of Matlab; the syntax is identical in the computational part and slightly different in the graphic output part.

x = (11-2)*rand(1000,1)+2*ones(1000,1)
histplot(30,x) 
t = 2:0.01:11
f = (1/(11-2))*ones(t)
plot(t,f)