-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormal.dist.html
56 lines (52 loc) · 2.31 KB
/
normal.dist.html
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
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="R package animation 2.5">
<title>Normal Distribution</title>
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/scianimator.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="js/jquery.scianimator.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<div class="scianimator"><div id="density_normal_dist" style="display: inline-block;"></div></div>
<div class="scianimator" style="width: 600px; text-align: left"><pre><code class="r">## This animation plots the density functions of 150 draws of 100 values
## from a normally distributed random variable.
library(animation)
library(SNPRelate)
library(gdsfmt)
library(BiocInstaller)
layout(matrix(c(1, rep(2, 5)), 6, 1))
par(mar = c(3, 3, 1, 1) + 0.1)
for (i in 1:150) {
chunk <- rnorm(100) + sqrt(abs((i) - 51))
par(fg = 1)
plot(-5, xlim = c(1, 150), ylim = c(0, 0.3), axes = F,
xlab = "", ylab = "", main = "Iteration")
abline(v = i, lwd = 5, col = rgb(0, 0, 255, 255, maxColorValue = 255))
abline(v = i - 1, lwd = 5, col = rgb(0, 0, 255, 50, maxColorValue = 255))
abline(v = i - 2, lwd = 5, col = rgb(0, 0, 255, 25, maxColorValue = 255))
axis(1)
par(fg = col.range[mean(chunk) + 3])
plot(density(chunk), xlab = "x-value", xlim = c(-5, 15),
ylim = c(0, 0.6))
abline(v = mean(chunk), col = rgb(255, 0, 0, 255, maxColorValue = 255))
if (exists("lastmean")) {
abline(v = lastmean, col = rgb(255, 0, 0, 50, maxColorValue = 255))
prevlastmean <- lastmean
}
lastmean <- mean(chunk)
}
## R version 3.3.3 (2017-03-06)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Other packages: animation 2.5, SNPRelate 1.8.0, gdsfmt 1.10.1, BiocInstaller
## 1.24.0</code></pre></div>
<script src="js/density_normal_dist.js"></script>
<!-- highlight R code -->
</body>
</html>