I'm trying to find the maximum entropy distribution as such:

Assuming[Element[l, Reals], 
NSolve[Sum[Exp[l i] i/Sum[Exp[l j], {j, 0, 100}], {i, 0, 100}] == 50,l]]

but I then get answers such as

{l -> ConditionalExpression[
1. ((-1.11022*10^-16 - 0.652623 I) + (0. + 6.28319 I) C[1]), 
C[1] \[Element] Integers]}

which seem to be either identically zero or complex, which is not what I'm looking for.

Q1: What's happening and how can I get only the (real) answer I want, i.e., the that maximizes the entropy?

Also, I'd like to solve for sums involving for instance 3000 terms, but the kernel keeps crashing due to low memory.

Q2: What are some better, standard methods for finding maximum entropy distributions numerically in Mathematica?



1 Answer 1


Plot your system and see what you get:

f = Sum[Exp[l i] i/Sum[Exp[l j], {j, 0, 100}], {i, 0, 100}] //Simplify;
Plot[f - 50, {l, -1, 1}]

enter image description here

NSolve[f == 50, l, Reals]
{{l -> 0.}}
  • $\begingroup$ Thanks, that actually makes a lot of sense given the (probably faulty for my specific problem) distribution I've given. But why isn't "Assuming[Element[l,Reals]]" practically the same a adding the ",Reals" at the end of the NSolve options? $\endgroup$ Aug 17, 2016 at 12:44
  • 1
    $\begingroup$ @Lovsovs Look up in the documentation: Assuming and Solve. Solve[expr, vars, Reals] restricts all variables and parameters to belong to be Reals. Assuming doesn't for Solve. $\endgroup$
    – user36273
    Aug 17, 2016 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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