572 questions
0 votes
0 answers
49 views
Markov Chain prediction using Excel Macro - accuracy differs significantly in real time prediction and back testing
I have a macro for inventory replenishment prediction using Markov Chain. It uses data for last 10 days including today to predict inventory replenishment (rep R) or not (blank B). The model works ...
1 vote
1 answer
47 views
verifyEmpiricalToTheoretical() returns error, even when using character sequence?
I'm trying to compare an empirical sequence of discrete states against a theoretical Markov chain. I'm using the package "markovchain" in R. library(markovchain) states <- c("LRP&...
0 votes
0 answers
28 views
Viterbi Decoding Returns -Incorrect State Sequence with One-Hot Observations in MultinomialHMM (Tried v0.3.0, v0.3.2, and v0.3.3)
I'm experiencing unexpected behavior with the MultinomialHMM in hmmlearn. When using one-hot encoded observations (with n_trials=1), the Viterbi algorithm returns the state sequence incorrectly. In my ...
0 votes
0 answers
36 views
Applying reweighting to a 2D Ising Model
I cannot figure out why my Matlab code for extrapolating susceptibility using the reweighting method returns physically non-sensical graphs, even though the magnetization and energy series appear fine....
3 votes
1 answer
82 views
Generating all sequences and probabilities for a random process in R
I have a Markov Chain in R: set.seed(123) n_states <- 5 matrix <- matrix(runif(n_states^2), nrow=n_states) # set some transitions to 0 matrix[1, 4:5] <- 0 matrix[5, 1:3] <- 0 matrix[...
1 vote
1 answer
295 views
simulate markov chain using networkx and numpy
My goal is to simulate a Markov chain using networkx and numpy. I write the following code import numpy as np import networkx as nx states = [ 'distance', 'strike', 'knockout' ] ...
4 votes
1 answer
164 views
Adding and removing columns in a matrix within a for loop
I have this 4 state Markov Chain in R: I wrote the following (100 iteration) simulation that simulates 100 hospital patients (all patients start in state 1) and tracks which state they are in during ...
0 votes
1 answer
58 views
Transition matrices to fractional powers
I have a series of cumulative transition matrices (5y, 10y, ..., 30y), and am trying to get the one year annualised transition matrices defined as 1-Year Matrix ^ T = T-year Matrix So I am solving for ...
1 vote
1 answer
77 views
Unable to get DiscreteMarkovChain to work in PyMC
I am trying to fit a two-state regime-switching model using PyMC. The full model is given below. The exact details of the model are not important (if you're curious anyways, I'm trying to fit a ...
2 votes
0 answers
77 views
Creating a random Markov matrix using Numpy
A Markov matrix is a matrix whose rows sum to 1 and whose determinant is 1 (at least according to one definition). I am able to make a unimodular matrix using the following operation: b = b/(np.linalg....
0 votes
1 answer
177 views
Probability of visiting state k at least once during first n steps in finite state Markov Chain
Assuming a Markov Chain of $M$ states, and assuming starting from state $X_0$, I was wondering if there is a method to calculate the probability of visiting state $X_k$ at least once during first n ...
3 votes
2 answers
110 views
Error in Matrix %*% Matrix: requires numeric/complex matrix/vector arguments
I am trying to do matrix multiplication in R. I have successfully created and run the matrix Matrix1, but caught an error when trying to do the multiplication: Matrix1 = new("markovchain", ...
0 votes
0 answers
79 views
Transition probabilities in Continuous Time Markov Chain following Poisson Processes
Let's imagine we have the following states corresponding to the number of users in a system in a Continuous Time Markov Chain: ---- [10] ------ [11] ------ [12] ........... [17] The arrival of a new ...
0 votes
1 answer
66 views
How would I convert this 4x4 transiton matrix to a 2x2 transition matrix while maintaing that all rows sum to 1
Say I have a transition matrix with 4 states labeled 1 to 4 as follows: matrix = [[.25,.25,.5,0], [ 0,.25,.5,.25], [.25,.25,.25,.25], [.25,.25,0, .5 ]] Say I want to ...
1 vote
0 answers
48 views
Metropolis-Hastings algorithm in a lattice
Metropolis-Hastings (MH) algorithm is a MCMC method to compute high-dimensional integrals. It is usually formulated in the continuum version, i.e. the target function to be integrated is known. The ...