Discrete and continuous random variables distribution
古いコメントを表示
I want to plot normal Gaussian distribution
9 件のコメント
Walter Roberson
2022 年 2 月 26 日
randi() can be used to generate the random values. However I do not understand what you are plotting.
John D'Errico
2022 年 2 月 26 日
A coin toss is NOT Gaussian. However, the law of large numbers tells you that the sum of MANY coin tosses will be effectively the sum of many iid binomial random variables, which in aggregate, will be approximately and asymptotically normally distributed.
Walter Roberson
2022 年 2 月 26 日
Sometimes for this purpose you want to generate a 2d array of random values 0 1, and sum them along one dimension and divide by the length of the dimension. There result is an experimental probability that the coin was in a particular state after that many tosses. The other dimension corresponds to repeating the experiment.
Torsten
2022 年 2 月 26 日
The OP searches for the PDF and CDF for a random variable which gives 0 with probability 0.5 and a number drawn from the standard normal distribution also with probability 0.5.
Walter Roberson
2022 年 2 月 27 日
I do not agree. The question specifically mentions discrete random variables. That is not the same as "a random variable which gives 0 with probability 0.5".
Consider a symmetric beta distribtution over
to
. Then there is a value of α for which the peak PDF would be 0.5 at x = 0 -- but it would not be a discrete distribution.
In my opinion, the OP searches for the PDF and CDF of a "mixture" random variable (i.e. a random variable that is neither discrete nor continuous). There will be a discontinuity at x=0 for the PDF as well as for the CDF. In all other points, it will be continuous.
Walter Roberson
2022 年 2 月 27 日
Unfortunately the poster edited away the original question. It referred to coin tosses -- and coin tosses are discrete.
I believe they were being asked to simulate coin tosses and determine an imperical PDF and CDF.
I only remember the OP's name: Mohamed Wnis.
The problem was that a random variable was defined to give 0 if the coin toss gave tail and to give a number randomly drawn from the standard normal distribution if the coin toss gave head.
Walter Roberson
2022 年 2 月 27 日
Oh... maybe! The wording of it was rather confusing!
採用された回答
その他の回答 (2 件)
"tosses a coin and the result is head, and if the result is tail plot 0 in that point,"
Here's a start
numTosses = 30;
tosses = randi([0,1], numTosses, 1);
bar(tosses);
grid on;
xlabel('Toss Number');
2 件のコメント
john adam
2022 年 2 月 26 日
Image Analyst
2022 年 2 月 26 日
Looks like you're all set now since you accepted the other answer.
Walter Roberson
2022 年 2 月 27 日
0 投票
For this purpose you want to generate a 2d array of random values 0 1, and sum them along one dimension and divide by the length of the dimension. There result is an experimental probability that the coin was in a particular state after that many tosses. The other dimension corresponds to repeating the experiment. Histogram the experimental probabilities to get pdf. cumsum the pdf to get the cdf.
カテゴリ
ヘルプ センター および File Exchange で Exploration and Visualization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
