probability or statistics – Discrete versions of `MultinormalDistribution` (aka Ising or multivariate Bernoulli)

I’m interested in obtaining functionality of Mathematica’s of Cumulant, Moment and RandomVariate for the distribution over $xin {-1,1}^d$ and/or $xin{0,1}^d$ with the following cumulant generating function:

$$log Z = frac{1}{2}x’Sigma x$$

To form is identical to the CDF of MultinormalDistribution, but the domain of $x_i$ is discrete, and correspondingly, $Sigma$ doesn’t have to be positive semidefinite. I have some ugly 12-year old Mathematica code for this, but looking for tips in implementing this in a modern way

Blood type with conditional probability

Everyone has 2 copies of the A/B/O gene. One gene is inherited from the mother and the other from the father. Everyone has a 1/2 probability to pass a randomly selected gene copy to their children.
Choosing to focus on A and O, people with AA or AO genes have blood type A; those with OO have type O blood. Suppose Eve and both her parents have blood type A, but her sister Eva has blood type O. Eve marries Adam, who has blood type O.

(a) If Eve and Adam’s first child had blood type A, what is the probability that Eve carries an O gene?

(b) If Eve and Adam’s first child had type A blood, what is the probability that their second child will as well?

So far I’ve done:

Let A = Eve carries an O gene, and C = first child has type A blood

P(A) = 6/12 = 1/2 because Eve’s parents have to be either AO/AO, AO/AA, AA/AO (they cannot be AA/AA because Eve’s sister has blood type O)

P(C) = 6/8 = 3/4 because parents have to be AA/OO or AO/OO.

I believe part a) is asking for P(A|C) = $frac{P(C|A)P(A)}{P(C)}$

However, I’m not sure how to calculate P(C|A) or the probability that the first child has type A blood given Eve carries an O gene.

pr.probability – Example of a strictly proper scoring rule defined on the set of all probability measures on $[0,1]$

This question is closely related to another question I asked recently but is more to the point than that other question.

Let $mathcal P$ be the set of all probability measures on the Borel algebra of $(0,1)$. A measurable scoring rule $S: mathcal P times (0,1) to (-infty, 0)$ is called strictly proper if
$$int S(P,x)P(dx) > int S(Q, x)P(dx)$$
holds for all $P neq Q$ in $mathcal P$.

Can anyone provide a concrete example of a strictly proper scoring rule?

probability – Variational inference for a latent dirichlet allocation model

I read the LDA paper multiple times but I’m having trouble with the following. Let’s say I define a LDA model as:

  • For each sentence $m$:
    • Sample sentiment probabilities $theta_m sim Dirichlet(alpha)$
    • For each words $n$:
      • Sample a sentiment $s_{mn} sim Multinomial(theta_m)$
      • Sample a word $t_{mn} sim Multinomial(beta)$

Where $alpha, beta$ are fixed hyperarameters.

I’d like to find some probability distribution that approximates the real probability distribution of the model by minimizing the KL-divergence $K(q_{gamma_m, phi_m}(theta, s) || p(theta, s|t))$ in terms of $phi, gamma$. I’m defining $q_{gamma, phi}(theta, s) = q_{gamma}(theta)Pi_nq_{phi_n}(s_n), q_gamma(theta)$ and $q_{phi_n}(s_n)$ is multinomial. I’m not even where to start with generating a mean-field variational inference algorithm for this model.

Computing conditional probability with uniform distribution

Suppose that parameter $theta$ characterizes the probability that an individual takes an action. In the population, $thetasim U(0,1)$. Individual i has probability $pi(theta_i)$ of taking the action. Suppose further that

pi(theta_i)=begin{cases} pi_1 & if & thetaleq c\
pi_2 & if & else

What is the correct formula for the average probability? Is it
pi&=&int pi_i di\
&=&int_{0}^c pi_1 di +int_{c}^1 pi_2 di

or is it

pi&=&int pi_i di\
&=&Prob(thetaleq c)int_{0}^1 pi_1 di +Prob(thetageq c)int_{c}^1 pi_2 di

probability or statistics – Plotting Gaussian using a formula

I am able to plot a Gaussian distribution of mean 10 and Standard deviation using below code.

ListLinePlot(Table(PDF(NormalDistribution(10, 2), x), {x, 0, 20}), 
 PlotMarkers -> {Automatic, 10}, PlotStyle -> Blue, Frame -> True, 
 FrameStyle -> Directive(Black, 15))

But when I use a formula,
I can’t get a plot when I write a code as follows:

(Lambda) = .125
a = 10
(Rho)(x_) := A*Exp(-(Lambda)*(x - a)^2)
Replace((Rho)(x), A -> Sqrt((Lambda))/Sqrt((Pi)), All)
Plot((Rho)(x), {x, 0, 20})

Here dd

probability or statistics – Mean age of people

values = {14, 15, 16, 22, 24, 25};
weights = {1, 1, 3, 2, 2, 5};

You can also use WeightedData:

Mean @ WeightedData[values, weights]

This also works with symbolic input:

values = Array[Subscript[x, #] &, 5];
weights = Array[Subscript[w, #] &, 5];

Mean @ WeightedData[values, weights] 

enter image description here

TeXForm @ %

$$frac{w_1 x_1+w_2 x_2+w_3 x_3+w_4 x_4+w_5 x_5}{w_1+w_2+w_3+w_4+w_5}$$

Probability and integration – Mathematica Stack Exchange


 time = Solve(x - (1/2)*g*(t^2) == 0, t)

 position = Solve(x - (1/2)*g*(t^2) == 0, x)

 v = D((g t^2)/2, t)

 T = Sqrt(2*h/g)

 dt = D((Sqrt(2) Sqrt(x))/Sqrt(g), x)

 Ptdt1 = dt1/T // PowerExpand

 Ptdt = 
 Replace(Ptdt1, {t -> (Sqrt(2) Sqrt(x))/Sqrt(g), 
   dt1 -> (1/(Sqrt(2) Sqrt(g) Sqrt(x)))*dx}, All)

 rhot = Ptdt/Ptdt((2))

 Integrate(rhot, {x, 0, h})

 Ex = Integrate(x*rhot, {x, 0, h})

 h = 20

 Plot(rhot, {x, 0, h}, AxesOrigin -> {0, 0})


Please see my code to do a problem in Griffith’s quantum mechanics. But I have a feel that my code is really lengthy and is not general. Is there a way to make this general? or any easy alternatives?