Generate independent random variables X , and X₂ with pdf f ( x₁ ) and f ( x₂ )
1 view (last 30 days)
Show older comments
- Plot the simulated pdf of the random number Z = X1 + X₂ - Determine the simulated mean and variance of resulting random numbers and compare them with theoretical value -Find the pdf of Z and compare with the simulation results
2 Comments
Torsten
on 28 Jun 2022
Are you able to generate random numbers for X1 and X2 ?
Are you able to add these random numbers to simulate Z ?
Are you able to get the mean and variance of the vector of generated random numbers for Z ?
Do you know how mean and variance for a sum of independent random vectors are computed ?
Do you know the convolution theorem to get the pdf for Z from those of X1 and X2 ?
Answers (1)
Moksh
on 6 Sep 2023
Hi Rose,
You can generate a uniform random distribution in MATLAB using the ‘rand’ function.
Further, the ‘histogram’ function in MATLAB provides the functionality of setting the ‘Normalization’ parameter through which you can plot the pdf for the random variable. Here is an example of this.
% Generate a random distribition for X1
X1 = randn(1, 1e5);
% Plotting the pdf
figure
histogram(X1, 'Normalization','pdf');
Similarly, you can create a distribution for ‘X2’ and create your required distribution ‘Z’.
Further you can use the ‘mean’ function for computing the mean of ‘Z’. For variance you can implement the standard formula using the ‘mean’ and ‘sum’ functions on ‘Z’.
For more information regarding the ‘rand’, ‘histogram’, ‘mean, and ‘sum’ functions please refer to the following documents.
Hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!