add user input for coin probability

This commit is contained in:
Chris Cromer 2022-09-05 16:29:28 -04:00
parent ec1b0be158
commit 63269d8c2d

View File

@ -93,6 +93,30 @@ pnorm_between <- function(dataset = vector(), min = 0, max = 0, word = "") {
dnorm_plot("out/dnorm_coins.png", sort(data[, 1]), "Coins Normal Distribution", xlab = "Coins") dnorm_plot("out/dnorm_coins.png", sort(data[, 1]), "Coins Normal Distribution", xlab = "Coins")
dnorm_plot("out/dnorm_time.png", sort(data[, 2]), "Time Normal Distribution", xlab = "Time (s)") dnorm_plot("out/dnorm_time.png", sort(data[, 2]), "Time Normal Distribution", xlab = "Time (s)")
pnorm_less(sort(data[, 1]), 5, "coins") min <- 0
pnorm_more(sort(data[, 1]), 5, "coins") max <- 13
pnorm_between(sort(data[, 1]), 8, 10, "coins") while (T) {
cat("Minimum number of coins: ")
input <- readLines("stdin", n = 1)
input <- as.numeric(input)
if (!is.na(input) && input >= min && input < max) {
min <- input
break
}
}
while (T) {
cat("Maximum number of coins: ")
input <- readLines("stdin", n = 1)
input <- as.numeric(input)
if (!is.na(input) && input > min && input <= max) {
max <- input
break
}
}
pnorm_less(sort(data[, 1]), min, "coins")
pnorm_more(sort(data[, 1]), min, "coins")
pnorm_less(sort(data[, 1]), max, "coins")
pnorm_more(sort(data[, 1]), max, "coins")
pnorm_between(sort(data[, 1]), min, max, "coins")