# Tag Info

2

In this particular case there's an easy explanation: Count[{a, b}, 0] immediately evaluates to 0, so we end up with Probability[ 0 != 2, ...], then Probability[True, ...], which is 1. To be able to give a warning, Probability would need to be HoldAll and check the arguments before they're evaluated. I do think that this is a somewhat tricky point, but the ...

3

EmpiricalDistribution can assign probabilities to each element in a set of discrete values: Here's an example: In[1]:= d = EmpiricalDistribution[{1/3, 1/2, 1/6} -> {1, 2, 3}]; In[2]:= Mean[d] Out[2]= 11/6 In[3]:= PDF[d, x] Out[3]= 1/3 Boole[1 == x] + 1/2 Boole[2 == x] + 1/6 Boole[3 == x] In[4]:= CDF[d, x] Out[4]= 1/3 Boole[1 <= x] + 1/2 Boole[2 ...

3

The biggest issue in trying to put this together is that NProbability mixed with EmpiricalDistribution doesn't seem to like array indexed variables. Building up symbols programatically seems to fix the issue. edfP[data_?MatrixQ][t__?NumericQ] /; Length[{t}] == Length[data[[1]]] := Block[{vars, x}, vars = Table[Symbol["x" <> ToString[i]], {i, ...

3

A transformed distribution should do what you want, e.g., dist=TransformedDistribution[a u + b, u \[Distributed] NormalDistribution[mu, sigma]] so in your case, distributed by your custom PDF. Be aware, while neat, MMA fancy-probability features have their limits...

3

Something like the following: dist = ProbabilityDistribution[ Convolve[PDF[NormalDistribution[4, 5], x], PDF[NormalDistribution[3, 1], x], x, t], {t, -Infinity, Infinity}] Expectation[z, z \[Distributed] dist] (* 7 *)

3

In Mathematica, the PDF of a GammaDistribution[a,b] is proportional to $$x^{a-1} e^{-\frac{x}{b}},$$ as described in the documentation. In R, dgamma(x, shape=a, rate=r) is a PDF proportional to $$x^{a-1} e^{-r x},$$ again as described in the documentation. R's rate $r$ is the same as Mathematica's $1/b$. Just make sure you use these parameters ...

2

It appears that Mathematica does not support discontinuous CDFs. For example, try F[x_] := ((Sign[x] + x) + 2)/4 dist = ProbabilityDistribution[{"CDF", F[x]}, {x, -1, 1}]; Plot[{F[x], CDF[dist, x]}, {x, -1, 1}] and you can see the results are not the same. Even if we define $F$ equivalently as G[x_] := Piecewise[{{(1 + x)/4, -1 <= x < 0}, {(3 + ...

Top 50 recent answers are included