I have a family of probability distributions, indexed by elements in $\mathcal I =\mathbb N \times [0,1] \times [0,1]$. For each $(A,B,C) \in \mathcal I$ I know how to define the corresponding distribution $\mathcal D_{A,B,C}$.
dist :=
ProbabilityDistribution[
PDF[BinomialDistribution[A, y*B + (1 - y)*0.5], x]
PDF[BernoulliDistribution[C], y],
{x, 0, A, 1},
{y, 0, A, 1}];
What I want is to define a probability distribution with parameters, so that fixing parameters n,p,q
will yield $\mathcal D_{A,B,C}$.
I have tried the obvious, e.g.
dist[n_,p_,q_] :=
ProbabilityDistribution[
PDF[BinomialDistribution[n, y*p + (1 - y)*0.5], x]
PDF[BernoulliDistribution[q], y],
{x, 0, n, 1},
{y, 0, n, 1}];
But I get an error message of the form SetDelayed::write: Tag ProbabilityDistribution in
...is Protected.
I'm thinking there's some simple solution I don't know about (I'm new to Mathematica). I have also tried this (I don't know whether it amounts to the same thing):
dist[n_, p_, q_] :=
ProbabilityDistribution[
PDF[BinomialDistribution[i, y*j + (1 - y)*0.5], x]
PDF[BernoulliDistribution[k], y],
{x, 0, i, 1},
{y, 0, i, 1}] /. {i -> n, j -> p, k -> q};
SetDelayed::write
message, they run fine for me on MMA 10.2… $\endgroup$dist
beforedist[...]
, so theSetDelayed
error is because yourdist[n_,p_,q_] := ...
statement is becomingProbabilityDistribution[...][n_,p_,q_] := ...
when evaluated. Does it work if youClearAll[dist]
first? $\endgroup$ProductDistribution[]
? $\endgroup$