Matlab continuous uniform distribution

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
freezer
Messages
75
Reaction score
0

Homework Statement


Generate 100 data points from a continuous uniform distribution with mean = 10 and variance = 4


Homework Equations



u = (a+b)/2

var = (b-a)^2 / 12

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


The Attempt at a Solution



Code:
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);
 
Physics news on Phys.org
freezer said:

Homework Statement


Generate 100 data points from a continuous uniform distribution with mean = 10 and variance = 4


Homework Equations



u = (a+b)/2

var = (b-a)^2 / 12

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


The Attempt at a Solution



Code:
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);

Do you have a question?
 
Oh yea... sorry.

So my code is not working. The poly solver is not generating numbers that i can us in 'r'.