markov-chains

Markov Chain: SQL Database and Java Representation

本小妞迷上赌 提交于 2019-12-08 08:15:51
问题 Now this question is a bit obscure. I have a text-based markov chain that I've generated by parsing user-typed text. It is used to generate an almost-coherent string of gibberish and works by storing the probability of a given word being the next word in a text sequence, based on the current word in the sequence. In javascript, this object would look something like the following: var text_markov_chain = { "apple" : { "cake" : 0.2, "sauce" : 0.8 }, "transformer" : { "movie" : 0.95, "cat" : 0

What's the octave equivalent of eig(X, 'nobalance')

我的梦境 提交于 2019-12-08 02:07:50
问题 I'm trying to find the equilibrium distribution of a markov chain, which means finding the eigenvalues of the transition matrix representing it, however, the eig function automatically normalises the eigenvectors it returns, in MatLab there is a flag you can pass to the function to stop this behaviour eig(X, 'nobalance') Where X is a matrix. See http://www.mathworks.com/help/techdoc/ref/eig.html. However, when I try this in octave I just get an error: error: eig: wrong type argument `sq

find Markov steady state with left eigenvalues (using numpy or scipy)

為{幸葍}努か 提交于 2019-12-06 13:32:05
问题 I need to find the steady state of Markov models using the left eigenvectors of their transition matrices using some python code. It has already been established in this question that scipy.linalg.eig fails to provide actual left eigenvectors as described, but a fix is demonstrated there. The official documentation is mostly useless and incomprehensible as usual. A bigger problem than than the incorrect format is that the eigenvalues produced are not in any particular order (not sorted and

What's the octave equivalent of eig(X, 'nobalance')

烂漫一生 提交于 2019-12-06 11:24:36
I'm trying to find the equilibrium distribution of a markov chain, which means finding the eigenvalues of the transition matrix representing it, however, the eig function automatically normalises the eigenvectors it returns, in MatLab there is a flag you can pass to the function to stop this behaviour eig(X, 'nobalance') Where X is a matrix. See http://www.mathworks.com/help/techdoc/ref/eig.html . However, when I try this in octave I just get an error: error: eig: wrong type argument `sq_string' Is there some other function I should be calling? Cheers If your goal is to compute the equilibrium

Left eigenvectors not giving correct (markov) stationary probability in scipy

流过昼夜 提交于 2019-12-06 06:16:02
问题 Given the following Markov Matrix: import numpy, scipy.linalg A = numpy.array([[0.9, 0.1],[0.15, 0.85]]) The stationary probability exists and is equal to [.6, .4] . This is easy to verify by taking a large power of the matrix: B = A.copy() for _ in xrange(10): B = numpy.dot(B,B) Here B[0] = [0.6, 0.4] . So far, so good. According to wikipedia: A stationary probability vector is defined as a vector that does not change under application of the transition matrix; that is, it is defined as a

How to use machine learning to calculate a graph of states from a sequence of data?

六眼飞鱼酱① 提交于 2019-12-05 20:02:53
Generic formulation I have a dataset consisting of a sequence of points with 12 features each. I am interested in detecting an event in this data. In the training data I know the moments the event occurred. When the event occurs I can see an observable pattern in the sequence of points before the event. The pattern is formed from about 300 consecutive points. I am interested in detecting when the event occurred in a infinite sequence of points. The analysis happens post factum. I am not interested in predicting if the event will occur. Concrete example You may skip this section I am building a

Markov chain on letter scale and random text

﹥>﹥吖頭↗ 提交于 2019-12-05 01:48:12
问题 I would like to generate a random text using letter frequencies from a book in a .txt file, so that each new character ( string.lowercase + ' ' ) depends on the previous one. How do I use Markov chains to do so? Or is it simpler to use 27 arrays with conditional frequencies for each letter? 回答1: I would like to generate a random text using letter frequencies from a book in a txt file Consider using collections.Counter to build-up the frequencies when looping over the text file two letters at

Rewriting a pymc script for parameter estimation in dynamical systems in pymc3

纵然是瞬间 提交于 2019-12-05 00:05:39
问题 I'd like to use pymc3 to estimate unknown parameters and states in a Hodgkin Huxley neuron model. My code in pymc is based off of http://healthyalgorithms.com/2010/10/19/mcmc-in-python-how-to-stick-a-statistical-model-on-a-system-dynamics-model-in-pymc/ and executes reasonably well. #parameter priors @deterministic def HH(priors in here) #model equations #return numpy arrays that somehow contain the probability distributions as elements return V,n,m,h #Make V deterministic in one line. Seems

Best way to calculate the fundamental matrix of an absorbing Markov Chain?

寵の児 提交于 2019-12-04 17:56:11
问题 I have a very large absorbing Markov chain (scales to problem size -- from 10 states to millions) that is very sparse (most states can react to only 4 or 5 other states). I need to calculate one row of the fundamental matrix of this chain (the average frequency of each state given one starting state). Normally, I'd do this by calculating (I - Q)^(-1) , but I haven't been able to find a good library that implements a sparse matrix inverse algorithm! I've seen a few papers on it, most of them P

Left eigenvectors not giving correct (markov) stationary probability in scipy

旧巷老猫 提交于 2019-12-04 10:10:48
Given the following Markov Matrix: import numpy, scipy.linalg A = numpy.array([[0.9, 0.1],[0.15, 0.85]]) The stationary probability exists and is equal to [.6, .4] . This is easy to verify by taking a large power of the matrix: B = A.copy() for _ in xrange(10): B = numpy.dot(B,B) Here B[0] = [0.6, 0.4] . So far, so good. According to wikipedia : A stationary probability vector is defined as a vector that does not change under application of the transition matrix; that is, it is defined as a left eigenvector of the probability matrix, associated with eigenvalue 1: So I should be able to