1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab continuous uniform distribution

  1. Mar 19, 2014 #1
    1. The problem statement, all variables and given/known data
    Generate 100 data points from a continuous uniform distribution with mean = 10 and variance = 4


    2. Relevant equations

    u = (a+b)/2

    var = (b-a)^2 / 12

    r = a + (b-a).*rand(100,1);


    3. The attempt at a solution

    Code (Text):


    points = 100

    m1 = 10
    v1 = 4

    syms a b
    [a, b] = solve( (a+b) == 2*m1,(b-a)^2 == 12 *v1)

     
    r = a + (b-a).*rand(points, 1);

     
     
  2. jcsd
  3. Mar 19, 2014 #2

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Do you have a question?
     
  4. Mar 19, 2014 #3
    Oh yea... sorry.

    So my code is not working. The poly solver is not generating numbers that i can us in 'r'.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted