# Tag Info

7

You can use ParameterMixtureDistribution Mean @ ParameterMixtureDistribution[PoissonDistribution[λ], Distributed[ λ, NormalDistribution[m, 1]]] Undefined We need to use a distribution with positive support for the distribution of λ: Mean @ ParameterMixtureDistribution[PoissonDistribution[λ], Distributed[ λ, LogNormalDistribution[m, 1]]] E^(1/2 + m) ...

5

pd = EmpiricalDistribution[({1, 1, 1, 1, 1, 5}/10) -> Range]; Probability[Total[Array[x, 4]] == 18, Thread[Array[x, 4] \[Distributed] pd]] (* result 12/125 *)

4

I hope this does the trick. It's more code than yours but I've come at it from a slightly different angle - I suppose another implementation can't hurt right? I've used FindPermutation to get $K_n$ and SolveAlways for non-square $G_n$: vec[W_] := Join @@ Transpose[W] vech[W_] := With[{n = Length[W]}, Flatten[MapThread[#1[[-#2 ;;]] &, {Transpose[W], ...

4

This is just an extended comment: Because the question is about speeding things up, I think you'll need to consider merging different functions depending on what values of $v$ are of most interest. Here is an example of the timing: f[r_, f_, v_] := Block[{t}, Coefficient[Expand[Sum[t^j/j!, {j, 0, v}]^(f - 1)] (f - 1)^(-(r - v))* (r - v)!*Binomial[r, v]/f^...

3

Without filtering: Total[Times @@@ Map[If[# == 6, 1/2, 1/10] &, Flatten[Permutations /@ IntegerPartitions[18, {4}, Range], 1], {2}]] 12/125

3

list = {P1, P2, P3, P4, P5}; Total[Flatten@ Table[(-1)^(k - 1) Times @@@ Subsets[list, {k}], {k, 1, 5}]] Update-1 Thanks to the suggestions in comments. list = {A1, A2, A3, A4, A5}; Sum[Total[(-1)^(k - 1) P /@ And @@@ Subsets[list, {k}]], {k, 1, 5}] Update-2 need to be updated later :)

3

This is now closer to an answer in that I attempted to follow @UlrichNeumann 's good suggestion about splitting the integration into parts. I changed the subscripted variables to x, y, and z to lighten the text load. The constraints in the Boole function can be written as 1 > x > y > z > 0 && z > 1 - x - y - z && x - z < 2 ...

2

Identities allow computing these matrices 100s of times faster  \begin{eqnarray} P_d&=&\text{nsymm[d], the symmetrizer matrix}\\ \mu&=&E[x]\\ X^2&=&E[xx']\\ E[(xx')(xx')]&=&2X ^2+X^2 \text{Tr} X^2 -2\|\mu\|^2 \mu \mu'\\ E[xx'\otimes xx']&=&2P_d( X^2\otimes X^2) + \text{vec} X^2 (\text{vec} X^2)'-2(\mu \mu')\otimes (\...

2

There are many works to start from: Propagation risk of COVID-19 by local contact in Spain 100 Days of COVID19 Over US Counties Maps for Visualizing Covid-19's Effect Also see works of Hiroki Sayama: CODE: https://github.com/hsayama/COVID-19-geographical-animations VISUALS: https://twitter.com/HirokiSayama/status/1261623727772631047 https://twitter.com/...

2

There's no need to use patterns here. They just make more trouble figuring them out and debugging. There's also no reason to introduce a coding scheme for the cards at this stage, which is a bit of a premature optimization. ranks[hand_] := Sort[hand[[All, 1]]] suits[hand_] := Sort[hand[[All, 2]]] countranks[hand_] := Values@Counts@ranks@hand pairQ[hand_] := ...

2

You can speed up the calculations for your initial equation several orders of magnitude (with ever larger increases in speed for larger values of k) by using Sort and Accumulate: (* Generate a random sample of positive numbers *) k = 100; SeedRandom; x = RandomVariate[ChiSquareDistribution, k]; (* Original equation *) t1 = AbsoluteTiming[Abs[1 - (...

1

PExpand[expr_] := Module[{A, B, expr1, f, H}, f = expr /. H_[___] -> H; expr1 = expr /. f[A___] -> A; f /@ Expand[expr1 //. A_ || B_ :> A (-B) + A + B] /. f[-B__] :> -f[Times[B]]] PExpand[P[Or @@ Array[Subscript[A, #1] &, 5]]]

1

What do you mean? The beta prime distribution is right here. Even if it wasn't, you could easily define it with TransformedDistribution as betaPrimeDistribution[α_, β_] := TransformedDistribution[ \[FormalX]/(1 - \[FormalX]), \[FormalX] \[Distributed] BetaDistribution[α, β] ]

Only top voted, non community-wiki answers of a minimum length are eligible