I have this distribution :
$X \sim 0.75\mathcal{B}e(\alpha_{X_1}=1,\beta_{X_1}=3)+0.25\mathcal{B}e(\alpha_{X_2}=5,\beta_{X_2}=1.75)$
where the density function is given from this function:
dmist2b=function(y,alpha1=1,beta1=3,p=0.25,alpha2=5,beta2=1.75) {
(1 - p) * dbeta(y, alpha1, beta1) + p * dbeta(y, alpha2, beta2)}
My problem is that I have to generate from $X$ but I'm having some troubles. Im'not found a r
library that implements this family of distributions.
I was wondering if this function that i implemeted returns the random values :
rmist2b <- function(n,alpha1,beta1,peso,alpha2,beta2) {
v <- rbinom(n,1,peso)+1
c(alpha1, alpha2)[v] + c(beta1,beta2)[v] * rbeta(n,shape1 = 0,shape2 = 0)
}
but i'm not sure that it's correct! What should I do? I think that I should first generate from two beta distribution, but in which way should I do?
Maybe someone has some ideas! Thank you in advance!