Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computing the limit of the lognormal density crashes Sage #26497

Open
EmmanuelCharpentier mannequin opened this issue Oct 16, 2018 · 3 comments
Open

Computing the limit of the lognormal density crashes Sage #26497

EmmanuelCharpentier mannequin opened this issue Oct 16, 2018 · 3 comments

Comments

@EmmanuelCharpentier
Copy link
Mannequin

EmmanuelCharpentier mannequin commented Oct 16, 2018

Define the lognormal density starting from the normal:

var("mu", domain="real")
var("y, m, s, sigma", domain="positive")
dnorm(x, mu, sigma) = e^(-(x-mu)^2/(2*sigma^2))/(sigma*sqrt(2*pi))
dlnorm(y, mu, sigma) = (dnorm(x, mu, sigma).subs(x==log(y))*abs(diff(log(y),y))).simplify()

Let's try to prove that the limit is 0 at 0 and oo:

sage: dlnorm(y, mu, sigma).limit(y=oo)
0

So far so good. But:

dlnorm(y, mu, sigma).limit(y=0, dir="+")
;;;
;;; Detected access to protected memory, also kwown as 'bus or segmentation fault'.
;;; Jumping to the outermost toplevel prompt
;;;

## Numerous repetitions...

Process Sage erreur de segmentation

This seems analogous to but different from #14677...

This limit also seems problematic in other subsystems:

  • Sympy returns "Not implemented"
  • libgiac returns "Infinity" (wrong)
  • Mathematica doesn't return (but (correctly) returns 0 when used directly).
  • Used directly, Maxima asks a lot of questions, and fails:
limit(dlnorm(y, mu, sigma), y, 0);
Is sigma^2-mu positive, negative or zero?

p;
Is mu positive, negative or zero?

p;
Is 2*sigma^2-mu positive, negative or zero?

p;
(%o10) ('limit(%e^-((log(y)-mu)^2/(2*sigma^2))/y,y,0))/(sqrt(2)*sqrt(%pi)
                                                               *sigma)

This failure mode is different from the one seen in Sage; we may have a new bug...

Upstream: Not yet reported upstream; Will do shortly.

CC: @slel

Component: symbolics

Keywords: limit, maxima

Issue created by migration from https://trac.sagemath.org/ticket/26497

@EmmanuelCharpentier EmmanuelCharpentier mannequin added this to the sage-8.4 milestone Oct 16, 2018
@nbruin
Copy link
Contributor

nbruin commented Oct 16, 2018

comment:1

It looks to me like a domain:complex error again. I get:

sage: maxima_calculus.eval("domain:real")
'real'
sage: dlnorm(y,mu,sigma).limit(y=0, dir="+")
0

That's to say, if we set domain to real, maxima in sage seems to do the right thing immediately. So I think it's basically the same problem as #14677.

@slel
Copy link
Member

slel commented Oct 18, 2018

Changed keywords from none to limit, maxima

@slel

This comment has been minimized.

@slel slel modified the milestones: sage-8.4, sage-8.5 Oct 18, 2018
@slel slel changed the title compiting the limit of the lognormal density crashes Sage. Computing the limit of the lognormal density crashes Sage Oct 18, 2018
@mkoeppe mkoeppe removed this from the sage-8.5 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants