![]() ![]() ![]() #create a function that will simulate the markov chain by randomly sampling for a given length #define our transition probabilities for three states, 1. I.e we have three boxes and we want to move between them. Lets say we wish to simulate a Markov chain with a certain probability transition matrix and a known initial state. The main highlight is that the process is sequential, hence for loops are used in simulating them. They are used in many contexts from brownian motion in physics to stock market time series trends. Markov chains is a sequence of random variables where the next value only depends on its previous value. Many researchers use markov chains in their research to simulate what a process might be doing. "Correlation between daily changes in aapl and ibm is -0.07."įor loops are very useful when it comes to simulations. "Correlation between daily changes in aapl and goog is 0.43." "Correlation between daily changes in aapl and fb is 0.44." "Correlation between daily changes in aapl and amzn is 0.53." Msg <- paste("Correlation between daily changes in aapl and ", sym, " is ", r, X being Apple’s % daily changes, Y being other companies’. In R for loops usually are constructed as such:Ĭhallenge 2: Let’s say I’m interested in knowing the relationship between daily % changes in Apple’s stock price, we can use cor(X, Y) to find out the correlation. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |