-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
markov.Rmd
executable file
·94 lines (75 loc) · 2.31 KB
/
markov.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: "Markov Processes"
subtitle: <h2>Predicting the future with the current state</h2>
author: "Eric Leung"
date: "2018 Jan 01"
output:
revealjs::revealjs_presentation:
theme: serif
highlight: tango
center: false
transition: fade
mathjax: default
fig_width: 7
fig_caption: true
css: custom.css
reveal_options:
slideNumber: true
---
## Overview
Motivating example
Basic definitions
Advanced topics
```{r Setup, echo=FALSE, message=FALSE, warning=FALSE}
library(DiagrammeR) # Create nice diagrams through presentation
```
## Let's start off with basics
Stochastic versus deterministic models
<img src="http://www.55cards.com/brettspiel/img/1001/100111_chesssnakes.gif" style="width: 75%"/>
Source: http://www.brettspiel.co.uk/2010/01/game-design-101-what-are-odds.html
## Abstract to state diagram
```{r, echo=FALSE}
grViz("
digraph markov {
// Set graph background to be transparent
graph [bgcolor=transparent];
rank = same; // Rank nodes to be the same
node [shape = circle];
fixedsize = true;
// Specify nodes
sick [width=0.8];
healthy [width=0.8];
{
// Specify directionality
sick:ne -> sick:nw;
healthy:nw -> healthy:ne;
sick -> healthy;
healthy -> sick;
}
}
")
```
## Two column slide
<div class = "column-left">
```{r cars, warning = FALSE, echo = FALSE, dev=c('svg')}
plot(pressure)
```
</div>
<div class = "column-right">
```{r pressure, warning = FALSE, echo=FALSE, dev=c('svg')}
plot(pressure)
```
</div>
## Key functions in R and Python
| R | Python (`import numpy as np`) |
|--------------|-------------------------------|
| matrix() | np.array() |
| %*% | np.dot() |
| t() | A.T |
| diag() | A.diagonal() |
| rbind, cbind | ustack, hstack |
| solve | np.linalg.solve() |
## Resources
- [Visual Explanation of Markov Chains](http://setosa.io/blog/2014/07/26/markov-chains/index.html)
- [Brilliant: Markov Chains](https://brilliant.org/wiki/markov-chains/)
- ["That's Maths: Andrey Markov's brilliant ideas are still bearing fruit"](https://www.irishtimes.com/news/science/that-s-maths-andrey-markov-s-brilliant-ideas-are-still-bearing-fruit-1.3220929)