How to plot a beta distribution which is a addition of two random variables...
Show older comments
I wanted to plot a beta distribution of X such that....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) for the values (0.5,0.5),(5,1),(1,3)...the code i have written for 0.5,0.5 is
U1 = rand;
U2 = rand;
alpha = 0.5;
beta = 0.5;
Y1 = U1^(1/alpha);
Y2 = U2^(i/beta);
X = Y1/(Y1+Y2);
I was stuck here as how to plot this and include all the other values as well....How do i do that??
1 Comment
Jonas
on 18 Apr 2021
without knowing anything about beta distributions i would extend your code in such a way that i repeat your procedure mutiple times and plot it into a histogram like
N=100000;
rng('shuffle');
U1 = rand(N,1);
rng('shuffle');
U2 = rand(N,1);
alpha = 0.5;
beta = 0.5;
Y1 = U1.^(1/alpha);
Y2 = U2.^(1/beta);
X = Y1./(Y1+Y2);
histogram(X,'Normalization','probability')
actually i don't know if this is what you wanted. you can repeat this for alpha or beta beeing (5,1),(1,3)
Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!