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!
