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
#!/bin/bash | |
display_cpu_util() { | |
while true; do | |
cpu_util=$(sar -u 1 1 | awk '/^Average:.*all/ {print 100-$NF}') | |
dialog --title "CPU Utilization" --infobox "CPU Utilization: $cpu_util %" 5 40 | |
done | |
} | |
display_cpu_util |
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
n_ <- 2000 | |
m_ <- 10000 | |
g <- ggplot(roll(m = m_, n = n_), | |
mapping = aes(x = V1)) + | |
geom_vline(xintercept = 3.5, colour = "tomato3") + | |
labs( | |
subtitle = str_interp('Density of means of dice | |
rolls for ${n_} dice over ${m_} rolls.'), | |
x = 'Mean Score', |
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
n_ <- 20 | |
m_ <- 10000 | |
g <- ggplot(roll(m = m_, n = n_), | |
mapping = aes(x = V1)) + | |
geom_vline(xintercept = 3.5, colour = "tomato3") + | |
labs( | |
subtitle = str_interp('Density of means of dice | |
rolls for ${n_} dice over ${m_} rolls.'), | |
x = 'Mean Score', |
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
n_ <- 4 | |
m_ <- 10000 | |
g <- ggplot(roll(m = m_, n = n_), | |
mapping = aes(x = V1)) + | |
geom_vline(xintercept = 3.5, colour = "tomato3") + | |
labs( | |
subtitle = str_interp('Density of means of dice | |
rolls for ${n_} dice over ${m_} rolls.'), | |
x = 'Mean Score', |
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
n_ <- 2 | |
m_ <- 10000 | |
g <- ggplot(roll(m = m_, n = n_), | |
mapping = aes(x = V1)) + | |
geom_vline(xintercept = 3.5, colour = "tomato3") + | |
labs( | |
subtitle = str_interp('Density of means of dice | |
rolls for ${n_} dice over ${m_} rolls.'), | |
x = 'Mean Score', |
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
g <- g + | |
geom_density() | |
g |
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
n_ <- 1 | |
m_ <- 10000 | |
g <- ggplot(roll(m = m_, n = n_), | |
mapping = aes(x = V1)) + | |
geom_vline(xintercept = 3.5, colour = "tomato3") + | |
labs( | |
subtitle = str_interp('Density of means of dice | |
rolls for ${n_} dice over ${m_} rolls.'), | |
x = 'Mean Score', |
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
#roll, as in roll di(c)e | |
# m = number of times | |
# n = number of dice | |
roll <- function(m, n){ | |
set.seed(1234) | |
means <- plyr::ldply(1:m, function(x){ | |
return(mean(sample(1:6, n, replace = TRUE))) | |
}) | |
} |
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
number_of_rolls <- 1000000 # Or, we could manually roll a die 1 million times. Nah, let's let the computer do it. | |
mean(sample(1:6, number_of_rolls, replace = TRUE)) | |
# [1] 3.499435 |
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
row1 <- c(2, 3, 4, 5, 6, 7) / 2 | |
row2 <- c(3, 4, 5, 6, 7, 8) / 2 | |
row3 <- c(4, 5, 6, 7, 8, 9) / 2 | |
row4 <- c(5, 6, 7, 8, 9, 10) / 2 | |
row5 <- c(6, 7, 8, 9, 10, 11) / 2 | |
row6 <- c(7, 8, 9, 10, 11, 12) / 2 | |
dice <- matrix(c(row1, row2, row3, row4, row5, row6), nrow = 6, byrow = TRUE) | |
dice |
NewerOlder