Question: new user having trouble creating a custom probability mass function

I have successfully created a a function of Y for the Beta-Binomial probability masss function using the built in distributions for the beta probability density function and the binomial probability mass function. However, despite trying many different things, I cannot take that function and turn it into a probability distribution for a random variable.  Of the code given below, all lines work except the last.  If someone could please help me, I would be most appreciative.

fYgivP := proc (Y) options operator, arrow; ProbabilityFunction(Binomial(n, P), Y) end proc

fP := proc (P) options operator, arrow; ProbabilityDensityFunction(('Beta')(a, b), P) end proc

fYandP := proc (Y, P) options operator, arrow; fYgivP(Y)*fP(P) end proc

fY := proc (Y) options operator, arrow; int(fYandP(Y, P), P = 0 .. 1) end proc

BB:=Distribution(ProbabilityFunction= X->piecewise(X<0,0,X>=0,  unapply(fX(X),X)))

Please Wait...