I am trying to make a maximum likelihood assessment (MLE) for the geometric Buryat movement with Theano. I know that Theano is primarily an ML library, but it should work ... (of course, I'm just trying to use Theano, and my ultimate goal is to make MLE for a slightly more complex model ....)
Writing math in SO is a bitch, so look for GBM, for example. here .
Here is the Theano code, which is slightly modified from the logistic regression example in Theano's tutorial:
training_steps = 1000
dt = 1/390
NT = len(Xdata)
rng = np.random
rate = 0.001
X = T.vector("X")
dX = T.vector("dX")
mu = theano.shared(rng.randn(), name="mu")
sigma2 = theano.shared(rng.random(), name="sigma2")
print("Initial model:")
print(mu.get_value())
print(sigma2.get_value())
eps = (dX - mu*dt*X)/X
summand1 = eps**2
loghood = summand1.sum()/sigma2/dt + NT*T.log(sigma2)
gmu, gsigma2 = T.grad(loghood, [mu, sigma2])
train = theano.function(
inputs=[X,dX],
outputs=[loghood],
updates=((mu, mu - rate * gmu), (sigma2, sigma2 - rate * gsigma2)))
costlist = []
mulist = []
siglist = []
for i in range(training_steps):
cost = train(Xdata, dXdata)
costlist.append(cost[0])
mulist.append(mu.get_value())
siglist.append(sigma2.get_value())
print("Final model:")
print(mu.get_value())
print(sigma2.get_value())
plot(costlist)
- loghood - logarithmic probability, which should be minimized wrt mu and sigma2
- Xdata is modeled from GBM, dXdata [n] = Xdata [n + 1] - Xdata [n]
- ,
- , ,
, , OK mu, sigma2, 2, mu, sigma2 , , , , , : s...
MLE, scipy.optimize.minimize, . , - "" , ...
- , ?