Binomial Distribution when mean and variance is given

50 Ansichten (letzte 30 Tage)
Soham Baste
Soham Baste am 11 Apr. 2021
Kommentiert: dpb am 11 Apr. 2021
How do i plot a Binomial Distribution when i have been given its mean and variance for example like mean = 3, variance = 3 or 0.5,2.......these values dont satisfy the conditions for mean and variance which are mean should lie between 0 and 1 and variance should be less than mean(mean - 1)...But these are the values i have to find the binomial distribution for...this is code i have written....
mu = 3;
var = 3;
alpha = (((1-mu)/var)-1/mu).*mu^2;
beta = alpha((1/mu) - 1);
X = 0:0.01:1;
Y = betapdf(X,alpha,beta);
%plot(X,Y,'LineWidth',1);
xlabel('Thetha');
hold on
mu2 = 0.5;
var2 =2 ;
alpha2 = (((1-mu2)/var2)-1/mu2).*mu2^2;
beta2 = alpha2((1/mu2) - 1);
X2 = 0:0.01:1;
Y2 = betapdf(X2,alpha2,beta2);
plot(X2,Y2,'LineWidth',1);
hold off;

Akzeptierte Antwort

dpb
dpb am 11 Apr. 2021
Well, sometimes one is given a nonsensical problem -- if so, then one has to inform the requestor of the fact and get a different problem formulation.
For a binomial you can write that
E(x)=np
V(x)=np(1-p) --> E(x)(1-p) or
V(x)/E(x)=(1-p) --> p=1-V(x)/E(x)
from which, if one is given values for both V and E, it's directly computable what pest must be. If it is outside [0,1], then the result is nonsensical and you have no choice but to return that result.
For the first case of V,E = 3, the answer is that p=0 and then the mean will be identical to 0 so that, too is nonsensical even though one can "solve" the two simultaneous equations algebraically to compute a value that satisfies the composite value of the quantitiy NP as a value, when substitute back to find
n=E/p --> inf
In short, the short answer is "You can't!" and shouldn't even try; simply check the bounds of the input and return error indication if the needed assumptions are not met.
That said, perhaps if we knew something of the problem space there might be some alternative interpretation to be made of the data and some other way to approach it rather than by the impossible.
  3 Kommentare
Soham Baste
Soham Baste am 11 Apr. 2021
Yeahh i did just that ...... the professor did reply saying you can choose values which fit the constraints but posed another question also which was....."Consider U1 and U2 are uniform random variables. There are two random variables Y1 = U1^1/α and Y2 = U2 ^1/β. A beta distribution is then given by X = Y1/(Y1 + Y2). Implement this algorithm and plot the PDF of the beta distribution for the values 0.5 and 0.1.......i was thinking of approaching it as so.....generating Uniform Random variables for U1 and U2,then taking the values of alpha and beta and using them for finding Y1 and Y2 ......then create X with the given formula.....i was stuck on how to plot it after this....could you suggest something?
dpb
dpb am 11 Apr. 2021
As written, that looks to me to be just a case of evaluating the given pdfs and then doing as you say, compute the given transformation with the two values for α and β. It would be an empirical pdf and cdf. MATLAB has functions for the latter if have Statistics TB and allowed to use it.
You could then fit the empirical to estimate coefficients of a beta distribution; there is, iirc, a specific function provided for it; nonlnear least-squares will do it otherwise.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by