Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to integrate the following expression:



f[x_, u_] := E^(-(x - u)/2)/(2*(1 + E^(-(x - u)/2))^2)

i.e. the PDF of the logistic distribution with s=2.

Also, the a's are positive integers.

The tricky part is that I want to integrate over all values of the p values that result in them forming a valid probability distribution, ie the p variables must be greater than zero, less than one and sum to 1.

I've tried using a definite integral with the following limits (after substituting p4 with $1-p1-p2-p3$:


This works for a simplified version of the problem (with 3 or 2 "f" terms and p variables but as soon as I use 4 it takes about 20 minutes and then just returns the input. My instinct is that if it can be analytically found for 3 terms, 4 terms should also be findable, just with more terms.

My question(s) are:

1) Does anyone have any suggestions to get Mathematica working for this (and larger problems)?

2) I'm not tied to the logistic distribution, I'm using it because I thought it's simple CDF would make the problem easy for Mathematica. Can anyone suggest a similar shaped distribution that would make this problem tractable?

share|improve this question
I think these limits don't ensure $0 \leq p_i \leq 1$ and $\sum_{i} p_i =1$. – Mahdi Jun 5 '14 at 4:02
Are you sure? That's what I saw other people solving similar problems (eg this post – Amit Deshwar Jul 5 '14 at 16:29

I think the problem is in limits you use because they don't ensure $0 \leq p_i \leq 1$ and $\sum_{i} p_i =1$. You have 4 $p_i$'s so you can only fix $p_4$. By using this relation, we can write the integrand as:

eq= f[a2, 1 - p1]*f[a3, 1 - p1 - p2]*f[a4, 1 - p1 - p2 - p3]*f[a1,1];

The last terms does not depend on $p_i$'s. Now you can easily find indefinite solution:


which is a function such that $g=g(p_1,p_2,p_3)$ with only one constraint $0 \leq p_1+p_2+p_3 \leq 1$. Then basically you can have value of $g$ over any valid combinations of $p_i$'s.

share|improve this answer
So once I've done this and I have g, then I still need to integrate over p1,p2,p3 with the constraint that they're positive and are less than one? – Amit Deshwar Jul 5 '14 at 16:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.