# Why does Maximize return this unevaluated?

Maximize[{PDF[NormalDistribution[0, sigma], x], sigma > 0}, x, Reals]


Just returns unevaluated (when, obviously, it should return 0 along with the function value there).

Any ideas?

Edit: This seems to be a general trend over many PDFs:

Maximize[{PDF[GammaDistribution[a, b], x], a > 0 && b > 0 && x > 0}, x]


returns unevaluated, as does:

Maximize[{PDF[LogNormalDistribution[mu, sigma], x], mu > 0 && sigma > 0 && x > 0}, x]


and:

Maximize[{PDF[StudentTDistribution[nu], x], nu > 0 && x > 0}, x]


and so on... I should have specified but I'm not interested in finding the modes of a specific case (like the normal), but more interested in why Mathematica can't handle these.

• As the output of Maximize[{(-(x^2/(2* sigma^2))), sigma > 0}, x] shows, the assumption is not taken into account. Jan 26 at 17:15
• I'd like to add that Maximize has problems with transcendental functions. Jan 26 at 17:23

A workaround
$Version (* "13.2.0 for Mac OS X x86 (64-bit) (November 18, 2022)" *) Clear["Global*"] f[x_] = PDF[NormalDistribution[0, sigma], x]; {max, arg} = Assuming[sigma > 0, {f[x] /. #, #} &[ Solve[ {D[#, x] == 0, D[#, {x, 2}] < 0} &[f[x]], x][[1]]]] (* {1/(Sqrt[2 π] sigma), {x -> 0}} *)  EDIT: More generally, f2[x_] = PDF[NormalDistribution[m, sigma], x]; {max, arg} = Assuming[sigma > 0 && m ∈ Reals, {f2[x] /. #, Reverse /@ #} &[{Simplify@Reduce[ {D[#, x] == 0, D[#, {x, 2}] < 0} &[f2[x]], x] // ToRules}[[1]]]] (* {1/(Sqrt[2 π] sigma), {x -> m}} *)  • Thanks @Bob. This is sort of beautiful in how hideously complex it is to accomplish a simple task! Jan 26 at 17:23 For some distributions taking the log of the density results in an answer: FullSimplify[ Maximize[{LogLikelihood[NormalDistribution[μ, sigma], {x}]}, x, Reals], Assumptions -> sigma > 0] (* {-(1/2) Log[2 π] - Log[sigma], {x -> μ}} *)  For others, more manipulations prior to using Maximize are necessary. Also, all 3 of your examples work if specific values are given for the parameters: Maximize[{PDF[GammaDistribution[3, 6], x], x > 0}, x] (* {1/(3 E^2), {x -> 12}} *) Maximize[{PDF[LogNormalDistribution[1, 2], x], x > 0}, x] (* {E/(2 Sqrt[2 π]), {x -> 1/E^3}} *) Maximize[PDF[StudentTDistribution[13], x], x] (* {1024/(231 Sqrt[13] π), {x -> 0}} *) ` • Thanks @JimB. Any idea just why Mathematica struggles with the PDFs as they stand? Jan 27 at 15:40 • I wouldn't use the word "struggles". Mathematica certainly decides in those situations that it can't find an answer. (Certainly that's better than producing a wrong answer.) And things are more complicated than restricting solutions to reals or positive reals. For example, the mode (which is what you're after) is not always finite. For a gamma distribution, the mode occurs at 0 for$0<a<1$and$(a-1)b$for$a\geq 1\$. Talking to Mathematica support might help.