ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Aug 2018 15:39:20 -0500Determine if hessian is positive semi-definitehttps://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/I have a log-likelihood function, and I am trying to determine if it is convex or concave to see if I can use standard optimization techniques. So I am trying to determine if the hessian is positive (or negative) semi-definite. This is what I have done:
from sage.symbolic.constants import Constant
var('E,a,k')
assume(k != 0)
assume(a > 0)
assume(E,'real')
Constant('x')
f(E,a,k) = -log(a - k * (x - E))
g(E,a,k) = -(log(1-k*(x-E)/a))^2/(2*k^2*s^2)
l(E,a,k) = f + g
solve(l.hessian() >= 0, [E,a,k])
However, I am getting this error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-90-f091cf87ab45> in <module>()
----> 1 solve(l.hessian() >= Integer(0), [E,a,k])
2
3
4
/usr/lib64/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
How can I fix this so I can get what I want? Is there a better way to do this?Sun, 26 Aug 2018 20:46:20 -0500https://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/Comment by dan_fulea for <p>I have a log-likelihood function, and I am trying to determine if it is convex or concave to see if I can use standard optimization techniques. So I am trying to determine if the hessian is positive (or negative) semi-definite. This is what I have done:</p>
<pre><code>from sage.symbolic.constants import Constant
var('E,a,k')
assume(k != 0)
assume(a > 0)
assume(E,'real')
Constant('x')
f(E,a,k) = -log(a - k * (x - E))
g(E,a,k) = -(log(1-k*(x-E)/a))^2/(2*k^2*s^2)
l(E,a,k) = f + g
solve(l.hessian() >= 0, [E,a,k])
</code></pre>
<p>However, I am getting this error:</p>
<pre><code>---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-90-f091cf87ab45> in <module>()
----> 1 solve(l.hessian() >= Integer(0), [E,a,k])
2
3
4
/usr/lib64/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
</code></pre>
<p>How can I fix this so I can get what I want? Is there a better way to do this?</p>
https://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/?comment=43533#post-id-43533Supposing that `s` is an `a`one can introduce with or without declaring constants `h.hessian()` which is a 3x3 matrix valued function with parameters. Now what do we want? That `h.hessian() >= 0` is too much, we can split this inequation in parts using diagonal minors, but also in that case the hessian will be positive semi-definite even *for fixed $x$* on a "complicated domain" (with boundary expected to be given by a transcendental equation). Please state in words what is needed / wanted. Please try to reduce the problem to a minimal one, for one fixed value of $x$. (Maybe even more, by fixing one of the three variables.)Thu, 30 Aug 2018 15:39:20 -0500https://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/?comment=43533#post-id-43533Comment by tmonteil for <p>I have a log-likelihood function, and I am trying to determine if it is convex or concave to see if I can use standard optimization techniques. So I am trying to determine if the hessian is positive (or negative) semi-definite. This is what I have done:</p>
<pre><code>from sage.symbolic.constants import Constant
var('E,a,k')
assume(k != 0)
assume(a > 0)
assume(E,'real')
Constant('x')
f(E,a,k) = -log(a - k * (x - E))
g(E,a,k) = -(log(1-k*(x-E)/a))^2/(2*k^2*s^2)
l(E,a,k) = f + g
solve(l.hessian() >= 0, [E,a,k])
</code></pre>
<p>However, I am getting this error:</p>
<pre><code>---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-90-f091cf87ab45> in <module>()
----> 1 solve(l.hessian() >= Integer(0), [E,a,k])
2
3
4
/usr/lib64/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
816
817 if not isinstance(f, (list, tuple)):
--> 818 raise TypeError("The first argument must be a symbolic expression or a list of symbolic expressions.")
819
820 if len(f)==1:
TypeError: The first argument must be a symbolic expression or a list of symbolic expressions.
</code></pre>
<p>How can I fix this so I can get what I want? Is there a better way to do this?</p>
https://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/?comment=43491#post-id-43491What is `s` ?Mon, 27 Aug 2018 12:33:27 -0500https://ask.sagemath.org/question/43479/determine-if-hessian-is-positive-semi-definite/?comment=43491#post-id-43491