Matlab continuous uniform distribution

In summary, the conversation discusses generating 100 data points from a continuous uniform distribution with a mean of 10 and a variance of 4. The equations used to solve for the data points are u = (a+b)/2 and var = (b-a)^2 / 12, with the final formula being r = a + (b-a).*rand(100,1). However, there seems to be an issue with the poly solver not generating usable numbers for 'r'.
  • #1
freezer
76
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
  • #2
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?
 
  • #3
Oh yea... sorry.

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

1. What is a continuous uniform distribution in Matlab?

A continuous uniform distribution in Matlab is a statistical distribution that represents a continuous range of values with equal probability. It is commonly used to model random variables that are equally likely to take on any value within a specified range.

2. How do I generate random numbers from a continuous uniform distribution in Matlab?

To generate random numbers from a continuous uniform distribution in Matlab, you can use the rand function with the uniform option. For example, rand(1,10,'uniform') will generate 10 random numbers between 0 and 1 with equal probability.

3. Can I specify the range of values for a continuous uniform distribution in Matlab?

Yes, you can specify the range of values for a continuous uniform distribution in Matlab by using the rand function with the uniform option and specifying the desired minimum and maximum values. For example, rand(1,10,'uniform', 5, 10) will generate 10 random numbers between 5 and 10 with equal probability.

4. How do I plot a continuous uniform distribution in Matlab?

To plot a continuous uniform distribution in Matlab, you can use the plot function with the pdf option. For example, plot(pdf('uniform',x,0,1)) will plot the probability density function for a continuous uniform distribution with a range of 0 to 1.

5. Are there any other functions in Matlab that can be used with a continuous uniform distribution?

Yes, there are several other functions in Matlab that can be used with a continuous uniform distribution, including cdf (cumulative distribution function), icdf (inverse cumulative distribution function), and fitdist (fitting a continuous distribution to data). These functions can be useful for statistical analysis and modeling with a continuous uniform distribution.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
13
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
586
  • Engineering and Comp Sci Homework Help
Replies
1
Views
978
  • Engineering and Comp Sci Homework Help
Replies
11
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
579
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
15
Views
2K
  • Calculus and Beyond Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top