# Getting non-real answers when assuming variable is real when trying to numerically find maximum entropy distribution

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),
C \[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?

Thanks!

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}] NSolve[f == 50, l, Reals]
{{l -> 0.}}

• 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? Aug 17, 2016 at 12:44
• @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.
– user36273
Aug 17, 2016 at 12:58