Questions tagged [markov-chains]

Markov chains are systems which transition from one state to another based only upon their current state. They are used widely in various statistical domains to generate sequences based upon probabilities.

Markov chains (named after their creator, Andrey Markov) are systems which transition from one state to another based only upon their current state. They are memoryless processes which are semi-random, i.e. where each state change having an associated probability.

Due to their statical nature, Markov chains are suitable for simulating complex real-life processes where probabilities are well known. They are used in a wide variety of fields, with uses too in-depth to list here; an exhaustive list can be found on the associated Wikipedia page.

In programming, they are especially popular for manipulating human languages - Markov text generators are especially popular applications of Markov chains.

577 questions
7
votes
1 answer

How to create a nested dictionary from existing dictionary with set and list of tuples

I have parsed a midi file, and I've successfully gotten a dictionary of notes broken up by instrument. An abbreviated example of this is note_dict below, truncated for the purposes of this question. My end goal is to have a nested dictionary that…
Tim
  • 71
  • 3
7
votes
1 answer

How to know where to join by space in spaCy NLP output

I am using spaCys NLP model to work out the POS of input data so that the my Markov chains can be a bit more gramatically correct as with the example in the python markovify library found here. However the way that spaCy splits tokens makes it…
Auh
  • 145
  • 11
7
votes
1 answer

understanding how to construct a higher order markov chain

Suppose I want to predict if a person is of class1=healthy or of class2= fever. I have a data set with the following domain: {normal,cold,dizzy} The transition matrix would contain the probability of transition generated from our training dataset…
Imlerith
  • 479
  • 1
  • 7
  • 15
7
votes
3 answers

R library for discrete Markov chain simulation

I am looking for something like the 'msm' package, but for discrete Markov chains. For example, if I had a transition matrix defined as such Pi <- matrix(c(1/3,1/3,1/3, 0,2/3,1/6, 2/3,0,1/2)) for states A,B,C. How can I simulate a Markov chain…
stevejb
  • 2,414
  • 5
  • 26
  • 41
6
votes
1 answer

How to visually animate Markov chains in Python?

I want to "visually" animate Markov chains like here : http://markov.yoriz.co.uk/ but using Python instead of html css and javascript. I don't know if there is any library that makes this easy, till now I managed to make a visual representation of…
mac179
  • 1,540
  • 1
  • 14
  • 24
6
votes
2 answers

How does MCMC help bayesian inference?

Literature says that the metropolis-hasting algorithm in MCMC is one of the most important algorithms developed last century and is revolutional. Literature also says that it is such development in MCMC that gave bayesian statistics a second birth.…
Kid_Learning_C
  • 2,605
  • 4
  • 39
  • 71
6
votes
6 answers

Building a Transition Matrix using words in Python/Numpy

Im trying to build a 3x3 transition matrix with this data days=['rain', 'rain', 'rain', 'clouds', 'rain', 'sun', 'clouds', 'clouds', 'rain', 'sun', 'rain', 'rain', 'clouds', 'clouds', 'sun', 'sun', 'clouds', 'clouds', 'rain', 'clouds', 'sun',…
m.umar
  • 855
  • 4
  • 13
  • 23
6
votes
4 answers

Generating a pseudo-natural phrase from a big integer in a reversible way

I have a large and "unique" integer (actually a SHA1 hash). Note: While I'm talking here about SHA1 hashes, this is not a cryptography / security question! I'm not trying to break SHA1. Imagine a random 160-bit integer instead of SHA1 if that will…
Alexander Gladysh
  • 39,865
  • 32
  • 103
  • 160
6
votes
2 answers

probability of each terminal node in a directed graph

I have a directed graph G(V,E) and weight w(u,v). In this graph weight w(u,v) represents how many times the node(v) has visited from node(u). for example(See this for a directed graph image): 1 3 A ----- B ----- D | \____/| 1| 4 …
ydrall
  • 338
  • 1
  • 3
  • 11
6
votes
2 answers

R : function to generate a mixture distribution

I need to generate samples from a mixed distribution 40% samples come from Gaussian(mean=2,sd=8) 20% samples come from Cauchy(location=25,scale=2) 40% samples come from Gaussian(mean = 10, sd=6) To do this, i wrote the following function : dmix…
Raaj
  • 1,180
  • 4
  • 18
  • 36
6
votes
2 answers

How to create paragraphs from markov chain output?

I would like to modify the script below so that it creates paragraphs out of a random number of the sentences generated by the script. In other words, concatenate a random number (like 1-5) of sentences before adding a newline. The script works fine…
6
votes
1 answer

Hidden markov model in MATLAB

I have 11 states, and a transition probability matrix, but I don't have emissions as my model is not hidden. It consists only of states (1,2,3, ..., 11) I want to generate random states based on my transition probability matrix, but the HMM tool box…
Radwa Mohamed
  • 61
  • 1
  • 1
  • 2
5
votes
1 answer

Converting First order logic to CNF

Is there a existing implementation in C/c++/java to convert first order logic to CNF ?
5
votes
1 answer

Hidden test cases not passing for Google Foobar Challenge Doomsday Fuel

I'm working my way through the Google Foobar challenge and am now at the level 3 challenge Doomsday Fuel. The instructions are as follows: Doomsday Fuel Making fuel for the LAMBCHOP's reactor core is a tricky process because of the exotic matter…
Guy Wilks
  • 53
  • 1
  • 1
  • 5
5
votes
0 answers

For-loop that loops over dates and months for extracting Google Analytics data in R in order to run Markov Chain Model

I am trying to build a Markov Chain digital attribution model using GA data. I would like some help with for loops for date ranges and then the creation of a column in my dataset which shows the month. The query extracts data from GA and…
1 2
3
38 39