Matlab continuous uniform distribution

Click For Summary
SUMMARY

The discussion focuses on generating 100 data points from a continuous uniform distribution in MATLAB, with a specified mean of 10 and variance of 4. The equations used include the mean formula \( u = \frac{(a+b)}{2} \) and the variance formula \( \text{var} = \frac{(b-a)^2}{12} \). The user encounters issues with the polynomial solver not producing usable values for 'a' and 'b', which are essential for generating the random points using the command \( r = a + (b-a).*rand(100,1) \).

PREREQUISITES
  • Understanding of continuous uniform distribution properties
  • Familiarity with MATLAB syntax and functions
  • Knowledge of solving equations symbolically in MATLAB
  • Basic statistics concepts, including mean and variance
NEXT STEPS
  • Learn how to use MATLAB's 'solve' function for symbolic equations
  • Research the properties of continuous uniform distributions
  • Explore MATLAB's random number generation functions
  • Investigate debugging techniques for MATLAB code
USEFUL FOR

Students and professionals working with MATLAB who need to generate random data from a continuous uniform distribution, as well as those troubleshooting symbolic equation solvers in MATLAB.

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'.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
15
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K