Can anybody help me to solve this?

2 visualizaciones (últimos 30 días)
ASWATHI V
ASWATHI V el 21 de Ag. de 2018
Comentada: Walter Roberson el 26 de Ag. de 2018
How to generate a Binomial random variable by using Bernoulli random variables? The idea is: (i) Generate Bernoulli random variables Yi's with mean p (ii) Set X = sum(Yi's).
This will give us a Binomial random variable with parameters n and p. (Convolution method). How to do this in MATLAB
  1 comentario
ASWATHI V
ASWATHI V el 21 de Ag. de 2018
Let random variable X = Y1+Y2+.....Yn. are iid rvs. We have to Generate Binomial(n,p) rv X. For this first, we have to generate Bernoulli rvs {Yi's} with mean p. Then we have to find X = Summation(Yi's) (summation is sigma from 1 to n). Then it will give us Binomial rv with parameters n and p. we have to plot the pdf and cdf of this result.

Iniciar sesión para comentar.

Respuestas (2)

Adam Danz
Adam Danz el 21 de Ag. de 2018
Editada: Adam Danz el 21 de Ag. de 2018
Does this help?
p=0.3;
n = 100000;
b=(rand(1,n)<p);
%test it
mean(b)
  2 comentarios
ASWATHI V
ASWATHI V el 22 de Ag. de 2018
Editada: ASWATHI V el 22 de Ag. de 2018
Is it similar to summation? We have to summed up 'n' Bernoulli random variables.
Adam Danz
Adam Danz el 22 de Ag. de 2018
I'm not sure what you mean. I don't know what this means: " Set X = sum(Yi's)."
If you want " a Binomial random variable with parameters n and p", then that's what I showed you. If you want to sum them,
x = sum(b)
It's not clear conceptually what you're looking for.

Iniciar sesión para comentar.


Torsten
Torsten el 22 de Ag. de 2018
Editada: Torsten el 22 de Ag. de 2018
p = 0.3;
n = 25;
nsample_binomial = 1000000;
for i = 1:nsample_binomial
bernoulli = (rand(1,n)<=p);
binomial(i) = sum(bernoulli);
end
%Test for mean and variance
mean(binomial)-n*p
var(binomial)-n*p*(1-p)
  4 comentarios
ASWATHI V
ASWATHI V el 26 de Ag. de 2018
But when I am plotting CDF and PDF it is not coming in the same way as we need. We cant use cdfplot for plotting CDF, First we have to plot the PDF and from that the CDF. But its not getting.

Iniciar sesión para comentar.

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by