The equation set is provided by 鲍珂 at 2014-8-12.
Host: Windows 7 VM: CentOS 6.5 minimal, python 2.6.6
Start VM, make sure its ssh service start with service sshd status
;
Then connect it with Putty or Kitty;
Install
yum install wget wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh epel-release-6-8.noarch.rpm yum update
// optional desktop environment, start with startxfce4
yum groupinstall Xfce
yum groupinstall Fonts
yum install xorg-x11-fonts-Type1 xorg-x11-fonts-misc
yum install python-pip yum install vim-enhanced yum install python-ipython.noarch pip install argparse pip install sympy pip install mpmath pip install scipy
Symbolic Method
from sympy import * var('x y s') integrate(gamma(x+y)/(gamma(x)+gamma(y))s(x-1)(1-s)(y-1), (s, 0, 0.6)) integrate(gamma(x+y)/(gamma(x)+gamma(y))*s(x-1)(1-s)*(y-1), (s, 0.9, 1))
Ref: http://docs.sympy.org/0.7.0/tutorial.html http://scipy-lectures.github.io/advanced/sympy.html#integration http://docs.sympy.org/dev/modules/integrals/integrals.html http://docs.sympy.org/0.7.1/modules/mpmath/functions/gamma.html
Numeric Method
from future import division from scipy.optimize import fsolve from scipy.special import gamma from scipy.integrate import fixed_quad
def myfunc(x, y, theta): gmp = gamma(x+y) / (gamma(x)+gamma(y)) return gmp * theta(x-1) * (1-theta)(y-1)
def equations(p): x, y = p intg1 = fixed_quad(myfunc, 0, 0.6, args=(x, y)) intg2 = fixed_quad(myfunc, 0.9, 1, args=(x, y)) return (intg1[0] - 0.05, intg2[0] - 0.05)
xr, yr = fsolve(equations, (1, 1)) print equations((xr, yr))
Ref:
http://stackoverflow.com/questions/8739227/how-to-solve-a-pair-of-nonlinear-equations-using-python
http://docs.scipy.org/doc/scipy-dev/reference/generated/scipy.integrate.fixed_quad.html#scipy.integrate.fixed_quad
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fsolve.html#scipy.optimize.fsolve