Skip to content

Instantly share code, notes, and snippets.

@grinsted
Last active December 19, 2017 09:27
Show Gist options
  • Save grinsted/50f238f06b5b209c7b70e9b9e08480b5 to your computer and use it in GitHub Desktop.
Save grinsted/50f238f06b5b209c7b70e9b9e08480b5 to your computer and use it in GitHub Desktop.
from sympy import *
init_printing(use_unicode=False, wrap_line=False, no_global=True)
x = Symbol('x', positive=True)
xmax = Symbol('xmax', positive=True)
sigma = Symbol('sigma', positive=True)
mu = Symbol('mu')
lx = log(x)-log(xmax-x)
pdf = exp(-0.5 * ((lx - mu)/sigma)**2) / (sqrt(2*pi) * sigma)
E = integrate(pdf*x,(x,0,xmax))
#----------------------
from sympy import *
init_printing(use_unicode=False, wrap_line=False, no_global=True)
lx = Symbol('lx')
xmax = Symbol('xmax', positive=True)
sigma = Symbol('sigma', positive=True)
mu = Symbol('mu')
x = xmax*exp(lx)/(exp(lx)+1)
pdf = exp(-0.5 * ((lx - mu)/sigma)**2) / (sqrt(2*pi) * sigma)
E = integrate(pdf*x,(lx,-oo,oo))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment