diff --git a/normal_distribution.R b/normal_distribution.R index b107986..2655ee8 100644 --- a/normal_distribution.R +++ b/normal_distribution.R @@ -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_time.png", sort(data[, 2]), "Time Normal Distribution", xlab = "Time (s)") -pnorm_less(sort(data[, 1]), 5, "coins") -pnorm_more(sort(data[, 1]), 5, "coins") -pnorm_between(sort(data[, 1]), 8, 10, "coins") +min <- 0 +max <- 13 +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")