Title: | Central Limit Theorem Experiments (Theoretical and Simulation) |
---|---|
Description: | Central limit theorem experiments presented by data frames or plots. Functions include generating theoretical sample space, corresponding probability, and simulated results as well. |
Authors: | Simiao Ye, Jingning Mei |
Maintainer: | Simiao Ye <[email protected]> |
License: | GPL-2 |
Version: | 1.3 |
Built: | 2025-02-14 03:40:02 UTC |
Source: | https://github.com/cran/clttools |
Histogram and Q-Q plot of simulated Beta distribution
beta.simu.plot(n, shape1, shape2, times, ylim = NULL, qqplot = FALSE)
beta.simu.plot(n, shape1, shape2, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
shape1 |
non-negative parameters of the Beta distribution |
shape2 |
non-negative parameters of the Beta distribution |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Beta distribution, red curve represents theoretical density
beta.simu.plot(n = 5, shape1 = 3, shape2 = 1, times = 100)
beta.simu.plot(n = 5, shape1 = 3, shape2 = 1, times = 100)
Histogram and Q-Q plot of simulated Binomial distribution
binom.simu.plot(n, size, prob, times, ylim = NULL, qqplot = FALSE)
binom.simu.plot(n, size, prob, times, ylim = NULL, qqplot = FALSE)
n |
number of observations |
size |
number of trials (zero or more) |
prob |
probability of success on each trial |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Binomial distribution, red curve represents theoretical density
binom.simu.plot(n = 10, size = 5, prob = 0.2, times = 100)
binom.simu.plot(n = 10, size = 5, prob = 0.2, times = 100)
Histogram and Q-Q plot of simulated Chi-Squared distribution
chisq.simu.plot(n, df, times, ylim = NULL, qqplot = FALSE)
chisq.simu.plot(n, df, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
df |
degrees of freedom (non-negative, but can be non-integer) |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Chi-Squared distribution, red curve represents theoretical density
chisq.simu.plot(n = 5, df = 4, times = 100)
chisq.simu.plot(n = 5, df = 4, times = 100)
Mean and probability of flipping fair or loaded coin
coin(n, prob = NULL)
coin(n, prob = NULL)
n |
number of trials |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all possible outcomes.
coin(n = 4) coin(6, c(0.1, 0.9))
coin(n = 4) coin(6, c(0.1, 0.9))
Probability plot of flipping fair or loaded coin
coin.plot(n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
coin.plot(n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
n |
number of trials |
prob |
probability assigned to each possible outcome |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all possible outcomes.
coin.plot(n = 4, col ='red', type = 'p') coin.plot(3, prob = c(0.3, 0.7))
coin.plot(n = 4, col ='red', type = 'p') coin.plot(3, prob = c(0.3, 0.7))
Mean and probability plot of flipping fair or loaded coin
coin.simu(n, times, prob = NULL)
coin.simu(n, times, prob = NULL)
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all simulated outcomes.
coin.simu(n = 4, times = 1000) coin.simu(4, 1000, prob = c(0.3, 0.7))
coin.simu(n = 4, times = 1000) coin.simu(4, 1000, prob = c(0.3, 0.7))
Probability plot of simulated experiments on flipping coins
coin.simu.plot(n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
coin.simu.plot(n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all simulated outcomes.
coin.simu.plot(n = 4, times = 1000, col = 'red') coin.simu.plot(4, 1000, prob = c(0.3, 0.7), type = 'p')
coin.simu.plot(n = 4, times = 1000, col = 'red') coin.simu.plot(4, 1000, prob = c(0.3, 0.7), type = 'p')
Mean and probability of rolling fair or loaded dice
dice(n, prob = NULL)
dice(n, prob = NULL)
n |
number of trials |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all possible outcomes.
dice(n = 4) dice(2, c(0.1, 0.2, 0.2, 0.1, 0.3, 0.1))
dice(n = 4) dice(2, c(0.1, 0.2, 0.2, 0.1, 0.3, 0.1))
Probability plot of rolling fair or loaded dice
dice.plot(n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
dice.plot(n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
n |
number of trials |
prob |
probability assigned to each possible outcome |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all possible outcomes.
dice.plot(n = 4, col ='red', type = 'p') dice.plot(3, prob = c(0.3, 0.1, 0.2, 0.1, 0.1, 0.2))
dice.plot(n = 4, col ='red', type = 'p') dice.plot(3, prob = c(0.3, 0.1, 0.2, 0.1, 0.1, 0.2))
Mean and probabilityf of flipping fair or loaded dice
dice.simu(n, times, prob = NULL)
dice.simu(n, times, prob = NULL)
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all simulated outcomes.
dice.simu(n = 4, times = 1000) dice.simu(4, 1000, prob = c(0.3, 0.1, 0.1, 0.1, 0.3, 0.1))
dice.simu(n = 4, times = 1000) dice.simu(4, 1000, prob = c(0.3, 0.1, 0.1, 0.1, 0.3, 0.1))
Probability plot of dice simulated experiments
dice.simu.plot(n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
dice.simu.plot(n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all simulated outcomes.
dice.simu.plot(n = 4, times = 1000, col = 'red') dice.simu.plot(4, 1000, prob = c(0.3, 0.1, 0.1, 0.1, 0.1, 0.3), type = 'p')
dice.simu.plot(n = 4, times = 1000, col = 'red') dice.simu.plot(4, 1000, prob = c(0.3, 0.1, 0.1, 0.1, 0.1, 0.3), type = 'p')
Histogram and Q-Q plot of any given continuous distribution
distr.simu.plot(distr, n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
distr.simu.plot(distr, n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
distr |
vector, all possible outcomes, population distribution |
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all simulated outcomes.
distr.simu.plot(distr = c(1,0.2,3.4,5,6.6,1.1,5,4.7,2.33,3), n = 4, times = 1000, col = 'red')
distr.simu.plot(distr = c(1,0.2,3.4,5,6.6,1.1,5,4.7,2.33,3), n = 4, times = 1000, col = 'red')
Histogram and Q-Q plot of simulated Exponential distribution
expo.simu.plot(n, rate = 1, times, ylim = NULL, qqplot = FALSE)
expo.simu.plot(n, rate = 1, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
rate |
vector of rates |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Exponential distribution, red curve represents theoretical density
expo.simu.plot(n = 5, rate = 2, times = 100)
expo.simu.plot(n = 5, rate = 2, times = 100)
General experiment with basic probability
expt(x, n, prob = NULL)
expt(x, n, prob = NULL)
x |
vector, possible outcomes in one trial of experiment |
n |
number of trials |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all possible outcomes.
expt(x = c(1:3), n = 4) expt(c(2:4), 3, prob = c(0.3, 0.5, 0.2))
expt(x = c(1:3), n = 4) expt(c(2:4), 3, prob = c(0.3, 0.5, 0.2))
Mean square error of simulated experiments
expt.mse(x, n, times, prob = NULL)
expt.mse(x, n, times, prob = NULL)
x |
vector, possible outcomes in one trial of experiment |
n |
number of trials |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean square error of simulated experiments
expt.mse(x = c(1:3), n = 4, times = 100) expt.mse(c(0.1, 4, 2), 3, times = 50, prob = c(0.3, 0.5, 0.2))
expt.mse(x = c(1:3), n = 4, times = 100) expt.mse(c(0.1, 4, 2), 3, times = 50, prob = c(0.3, 0.5, 0.2))
General experiment plot with basic probability
expt.plot(x, n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
expt.plot(x, n, prob = NULL, col = "black", type = NULL, main = NULL, sub = NULL)
x |
vector, possible outcomes in one trial of experiment |
n |
number of trials |
prob |
probability assigned to each possible outcome |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all possible outcomes.
expt.plot(x = c(1:3), n = 4, col ='red', type = 'p') expt.plot(c(2:4), 3, prob = c(0.3, 0.5, 0.2))
expt.plot(x = c(1:3), n = 4, col ='red', type = 'p') expt.plot(c(2:4), 3, prob = c(0.3, 0.5, 0.2))
Mean and probability of general simulated experiments
expt.simu(x, n, times, prob = NULL)
expt.simu(x, n, times, prob = NULL)
x |
vector, possible outcomes in one trial of experiment |
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Mean value and corresponding probabilities for all simulated outcomes.
expt.simu(x = c(1:3), n = 4, times = 1000) expt.simu(c(1:3), 4, 1000, prob = c(0.3, 0.1, 0.6))
expt.simu(x = c(1:3), n = 4, times = 1000) expt.simu(c(1:3), 4, 1000, prob = c(0.3, 0.1, 0.6))
Probability plot of general simulated experiments
expt.simu.plot(x, n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
expt.simu.plot(x, n, times, prob = NULL, qqplot = FALSE, col = "black", type = NULL, main = NULL, sub = NULL)
x |
vector, possible outcomes in one trial of experiment |
n |
number of trials in one simulation |
times |
number of simulations |
prob |
probability assigned to each possible outcome |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
col |
color of the plot |
type |
type of plot |
main |
an overall title for the plot |
sub |
a sub title for the plot |
The default probabilty equals to 1/n. All the assigned probabilites must between 0 and 1.
Plot of mean value and corresponding probabilities for all simulated outcomes.
expt.simu.plot(x = c(1:3), n = 4, times = 1000, col = 'red') expt.simu.plot(c(1:3), 4, 1000, prob = c(0.3, 0.1, 0.6), type = 'p')
expt.simu.plot(x = c(1:3), n = 4, times = 1000, col = 'red') expt.simu.plot(c(1:3), 4, 1000, prob = c(0.3, 0.1, 0.6), type = 'p')
Histogram and Q-Q plot of simulated Gamma distribution
gamm.simu.plot(n, shape, rate = 1, scale = 1/rate, times, ylim = NULL, qqplot = FALSE)
gamm.simu.plot(n, shape, rate = 1, scale = 1/rate, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
shape |
shape parameter |
rate |
vector of rates |
scale |
scale parameter |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Gamma distribution, red curve represents theoretical density
gamm.simu.plot(n = 5, shape = 3, rate = 1, times = 100)
gamm.simu.plot(n = 5, shape = 3, rate = 1, times = 100)
Histogram and Q-Q plot of simulated Geometric distribution
geom.simu.plot(n, prob, times, ylim = NULL, qqplot = FALSE)
geom.simu.plot(n, prob, times, ylim = NULL, qqplot = FALSE)
n |
number of observations |
prob |
probability of success on each trial |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Geometric distribution, red curve represents theoretical density
geom.simu.plot(n = 10, prob = 0.2, times = 100)
geom.simu.plot(n = 10, prob = 0.2, times = 100)
Histogram and Q-Q plot of simulated Hypergeometric distribution
hyper.simu.plot(n, a, b, k, times, ylim = NULL, qqplot = FALSE)
hyper.simu.plot(n, a, b, k, times, ylim = NULL, qqplot = FALSE)
n |
number of observations |
a |
the number of white balls in the urn |
b |
the number of black balls in the urn |
k |
the number of balls drawn from the urn |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Hypergeometric distribution, red curve represents theoretical density
hyper.simu.plot(n = 10, a = 10, b = 10, k = 5, times = 100)
hyper.simu.plot(n = 10, a = 10, b = 10, k = 5, times = 100)
Histogram and Q-Q plot of simulated Negative Binomial distribution
nbinom.simu.plot(n, size, prob, times, ylim = NULL, qqplot = FALSE)
nbinom.simu.plot(n, size, prob, times, ylim = NULL, qqplot = FALSE)
n |
number of observations |
size |
number of trials (zero or more) |
prob |
probability of success on each trial |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Negative Binomial distribution, red curve represents theoretical density
nbinom.simu.plot(n = 10, size = 5, prob = 0.2, times = 100)
nbinom.simu.plot(n = 10, size = 5, prob = 0.2, times = 100)
Histogram and Q-Q plot of simulated Normal distribution
normal.simu.plot(n, mean=0, sd=1, times, ylim = NULL, qqplot = FALSE)
normal.simu.plot(n, mean=0, sd=1, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
mean |
vector of means |
sd |
vector of standard deviations |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Normal distribution, red curve represents theoretical density
normal.simu.plot(n = 5, mean = 3, sd =2, times = 100)
normal.simu.plot(n = 5, mean = 3, sd =2, times = 100)
Histogram and Q-Q plot of simulated Poisson distribution
pois.simu.plot(n, lambda, times, ylim = NULL, qqplot = FALSE)
pois.simu.plot(n, lambda, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
lambda |
parameter of Poisson distribution |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Poisson distribution, red curve represents theoretical density
pois.simu.plot(n = 5, lambda = 3, times = 100)
pois.simu.plot(n = 5, lambda = 3, times = 100)
Histogram and Q-Q plot of simulated Uniform distribution
unif.simu.plot(n, min = 0, max = 1, times, ylim = NULL, qqplot = FALSE)
unif.simu.plot(n, min = 0, max = 1, times, ylim = NULL, qqplot = FALSE)
n |
number of trials in one simulation |
min |
possible minimum value of Uniform distribution. Must be finite |
max |
possible maximum value of Uniform distribution. Must be finite |
times |
number of simulations |
ylim |
range of y-axis |
qqplot |
an argument to output Q-Q plot or not, can be TRUE or FALSE |
Histogram and Q-Q plot of simulated Uniform distribution, red curve represents theoretical density
unif.simu.plot(n = 5, min = 3, max = 5, times = 100)
unif.simu.plot(n = 5, min = 3, max = 5, times = 100)