Ask Your Question

kayhan's profile - activity

2020-07-09 05:21:28 +0200 received badge  Famous Question (source)
2017-11-06 10:20:22 +0200 received badge  Notable Question (source)
2014-08-29 01:00:23 +0200 received badge  Popular Question (source)
2014-06-14 12:26:24 +0200 received badge  Popular Question (source)
2012-09-23 22:19:05 +0200 answered a question stack overflow in computing entropy

Thank you for your reply.

The answer is correct but just a few points for clarification of my mind:

  • maxima is able to compute the integral correctly but it totally different software and sage can interface with it. However the syntax is totally different.

  • The mystery that why sage cannot solve the integral is not resolved, right?

  • It is not clear why we need to define (mu > 0) even in maxima.

Again thank you for your reply.

2012-09-23 01:50:07 +0200 received badge  Student (source)
2012-09-22 23:38:30 +0200 commented answer stack overflow in computing entropy

sorry for my ignorance, but it is still unclear for me. What is maxima_console() ? I am using web-based interface, are you using something else? Do you think it is a bug? You mentioned default mode of integration in sage is maxima, how can I change it?

2012-09-22 23:24:01 +0200 commented answer stack overflow in computing entropy

where did you define "inf" and "minf" ? did you import a library to get the answer?

2012-09-22 20:42:12 +0200 asked a question stack overflow in computing entropy

Hi,

I am still new to sage, I am trying to compute use sage to do some symbolic computation. Here is my test to compute entropy of the Gaussian distribution:

x, sigma, mu,a = var('x','sigma','mu','a')
q = 1/((2*pi)^(1/2)*sigma)*exp(-(x - mu)^2/(2*sigma^2))
assume(sigma>0)
assume(mu>0)
show(q)
import sympy
integral(q,(x,-oo,oo)) 
integral(-q*log(q),(x,-oo,oo))

First of all, it complains if I don't assume mu is positive. It is right that sigma should be positive but why mu ?! Second, even after assuming mu>0, it produces stack overflow:

WARNING: Output truncated!  
full_output.txt


;;;
;;; Binding stack overflow.
;;; Jumping to the outermost toplevel prompt
;;;


;;;
;;; Binding stack overflow.
;;; Jumping to the outermost toplevel prompt
;;;

Does anyone know why? I am sure I am missing something.

2012-09-22 20:32:19 +0200 marked best answer newbie question about symbolic integration in sage
sage: x, sigma, mu = var('x','sigma','mu')                   
sage: q = 1/((2*pi)^(1/2)*sigma)*exp(-(x - mu)^2/(2*sigma^2))
sage: assume(sigma>0)                                        
sage: integral(q,(x,-oo,oo))                                     
1
2012-09-22 20:32:19 +0200 received badge  Scholar (source)
2012-09-22 20:25:18 +0200 commented answer newbie question about symbolic integration in sage

Thank you :) It is true that sign of sigma matters and what you said works and it yields "1". But when I type: integral(-q*log(q),(x,-oo,oo)) to compute entropy. it is still confused about sign of mu ?! even after assuming mu>0 produces stack overflow!

2012-09-22 20:24:57 +0200 received badge  Supporter (source)
2012-09-22 15:45:33 +0200 asked a question newbie question about symbolic integration in sage

Hi,

I am new to sage and my question can be naive, I apologize in advance. I would like to use sage for some symbolic integration operations to avoid human mistake. Here is my first test (which is going to important for my application).

Integration of Normal distribution from -infinity to +infinity. Obviously the result should be one and I am wondering why I don't get it:


x, sigma, mu = var('x','sigma','mu')

q = 1/((2*pi)^(1/2)*sigma)*exp(-(x - mu)^2/(2*sigma^2))

show(q)

import sympy

show((sympy.integrate(q, (x,-sympy.oo, sympy.oo))).simplify())

Here is the result:

Integral(2**(1/2)*exp(-mu**2/(2*sigma**2))*exp(-x**2/(2*sigma**2))*exp(mu*x/sigma**2)/(2*pi**(1/2)*sigma),(x,-oo,oo))

I am wondering why I don't get 1? Am I missing anything?

Thanks