Last active
July 12, 2019 10:48
-
-
Save Harshit1694/38af7616e9da59bcec83606058e5d4ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("markovchain") | |
install.packages("diagram") | |
library(markovchain) | |
library(diagram) | |
# Creating a transition matrix | |
trans_mat <- matrix(c(0.7,0.3,0.1,0.9),nrow = 2, byrow = TRUE) | |
trans_mat | |
# create the Discrete Time Markov Chain | |
disc_trans <- new("markovchain",transitionMatrix=trans_mat, states=c("Pepsi","Coke"), name="MC 1") | |
disc_trans | |
plot(disc_trans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment