Generate independent random variables X , and X₂ with pdf f ( x₁ ) and f ( x₂ )

6 ビュー (過去 30 日間)
Rose
Rose 2022 年 6 月 27 日
回答済み: Moksh 2023 年 9 月 6 日

- 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 件のコメント
Torsten
Torsten 2022 年 6 月 28 日
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 ?
Rose
Rose 2022 年 6 月 28 日
Thanks for the idea

サインインしてコメントする。

回答 (1 件)

Moksh
Moksh 2023 年 9 月 6 日
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!

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by