2. Probabilities and distribution laws

2.1 Binomial distribution (download)

Plot the graphic of a Binomial distribution.

Variables to customize:

- prob <- 0.1 # probability
- n <- 10 # number of independent experiments 
- barthickness <- 20 # thickness of the graphical bars
- colour <- rgb (1,0,0,0.5) # colour of the bars and line
2.2 Poisson distribution (download)

Plot the graphic of a Poisson distribution.

Variables to customize:

- lambda <- 3 # lambda parameter (mean and variance)
- n <- 20 # number of independent experiments
- ndecimals <- 5 # number of decimal places
- barthickness <- 15 # thickness of the graphical bars
- colour <- rgb (1,0,0,0.5) # colour of the bars and line

2.3 Uniform distribution (download)

Plot the graphic of an Uniform distribution and draw a set of values from the distribution.

Variables to customize:

- xmin <- 0.0 # minimum value
- xmax <- 1000.0 # maximum value
- ndecimals <- 2 # number of decimals
- nvalores <- 10 # number of values to generate by Monte Carlo simulation
- discretizacao <- 20 # number of points for graphical aproximation
- colour <- rgb (1,0,0,0.5) # colour of the lines

2.4 Triangular distribution (download)

Plot the graphic of a Triangular distribution and draw a set of values from the distribution.

Variables to customize:

- xmin <- 14.5 # minimum value
- xmax <- 32.5 # maximum value
- xmoda <- 30.0 # most likely value
- ndecimals <- 2 # number of decimals
- nvalores <- 100 # number of values to generate by Monte Carlo simulation
- discretizacao <- 200 # number of points for graphical aproximation
- colour = rgb(1,0,0,0.5) # colour of the lines

2.5 Normal distribution (download)

Plot the graphic of a Normal distribution and draw a set of values from the distribution.

Variables to customize:

- media=5.0 # mean of the normal distribution
- desvp=2.0 # standard deviation of the normal distribution
- ndecimals <- 2 # number of decimal places
- nvalores <- 10000 # number of values to generate by Monte Carlo simulation
- discretizacao <- 200 # number of points for graphical aproximation
- colour <- rgb (1,0,0,0.5) # colour of the lines

2.6 Lognormal distribution (download)

Plot the graphic of a Lognormal distribution and draw a set of values from the distribution.

Variables to customize:

- option -<- 1 # can be (1) mean and standard deviation are of the normal distribution, or (2) mean and standard deviation are of the lognormal values
- media=5.0 # mean of the normal or lognormal distribution
- desvp=2.0 # standard deviation of the normal or lognormal distribution
- ndecimals <- 2 # number of decimal places
- nvalores <- 10000 # number of values to generate by Monte Carlo simulation
- discretizacao <- 200 # number of points for graphical aproximation
- colour <- rgb (1,0,0,0.5) # colour of the lines

2.7 Normal distributions comparison (download)

Compare several Normal distributions, with different means and variances, in the same graph.

Variables to customize:

- media <- c(2,2,2,2,2) # mean of several normal distributions to compare
- desvp <- c(1,2,3,4,5) # standard deviation of several normal distributions to compare
- discretizacao <- 100 # number of points for graphical aproximation
- colours=c("red", "green", "blue", "yellow", "magenta") # list of colours of the several normal distributions to draw

2.8 Lognormal distribution comparison (download)

Compare several Lognormal distributions, with different means and variances, in the same graph.

Variables to customize:

- media <- c(2,2,2,2,2) # mean of several lognormal distributions to compare
- desvp <- c(1,2,3,4,5) # standard deviation of several lognormal distributions to compare
- discretizacao <- 100 # number of points for graphical aproximation
- colours=c("red", "green", "blue", "yellow", "magenta") # list of colours of the several normal distributions to draw

2.9 Power distribution (download)

Plot the graphic of a Power distribution.

Variables to customize:

- xmin <- 1 # minimum value of the distribution
- xmax <- 25 # maximum value of the distribution
- alfa <- 2 # power value of the distribution
- nclasses <- 25 # number of classes of the histogram
- discretizacao <- 1000 # number of points for graphical aproximation
- colour <- rgb (1,0,0,0.5) # colour of the bars and lines

2.10 Quantitative empirical distribution (download)

Plot the empirical distribution of a quantitative variable (simple histogram and cumulative histogram) and add the normal or lognormal distribution curve with the same mean and variance of the data.

Variables to customize:

- varlistindex <- 5 # index of the GD frame quantitative variable
- varunit <- "(ppm)" # units of the selected variable
- nclasses <- 15 # number of classes of the histogram
- fitmodel=TRUE #fit a model (TRUE) or nor (FALSE)
- modeltype="lognormal" # type of model, normal or lognormal only
- maxY=1.0 # maximum value for Y axis in the left graphic
- discretizacao <- 40 # number of points for graphical aproximation
- colourbar <- rgb(0,0,1,0.5) # colour of the histogram bars 
- colourline <- rgb(1,0,0,0.5) # colour of the histogram lines

2.11 Qualitative empirical distribution (download)

Plot the empirical distribution of a qualitative variable (simple histogram and pseudo-cumulative histogram).

Variables to customize:

- varlistindex <- 4 # index of the GTD frame variable
- sortbyfreq <- TRUE # (TRUE) rank histogram by frequency in decreasing order or (FALSE) present histogram by alfabetic order
- colourbar <- rgb(1,0,0,0.5) # colour of the histogram bars
- colourline <- rgb(1,0,0,0.5) # colour of the histogram lines

2.12 Mix normal distributions (download)

Use the Monte Carlo simulation to build a composite distribution mixing several normal distributions with different means and variances.

Variables to customize:

- nsims=500 # number of simulations (values to generate)
- probs=c(0.25,0.25,0.5) # proportions of each normal distribution, values must sum one.
- media=c(12,15,18) # means of several normal distributions to mix
- desviop=c(1,1,1) # standard variations of several normal distributions to mix
- nclasses <- 25 # number of classes in the mixure histogram
- valoravalia <- 15 # evaluate the probability of being below this valoravalia 
- colour <- rgb(0,0,1,0.5) # colour of the histogram bars and lines

2.13 Mix uniform distributions (download)

Use the Monte Carlo simulation to build a composite distribution mixing several uniform distributions with different intervals. The composite distribution is based on a simplified formula of Benefits B = PV x Q – CE x Q – CF

Variables to customize:

- nsims=500 # number of simulations (values to generate)
- Q=10000 # value for parameter Q
- minPV=4 # minimum value for PV variable uniformly distributed
- maxPV=6 # maximum value for PV variable uniformly distributed
- minCE=1.5 # minimum value for CE variable uniformly distributed
- maxCE=3.5 # maximum value for CE variable uniformly distributed
- minCF=13000 # minimum value for CF variable uniformly distributed
- maxCF=15000 # maximum value for CF variable uniformly distributed
- valoravalia <- 15 # evaluate the probability of being below this valoravalia
- nclasses <- 10 # number of classes in the mixure histogram
- colour <- rgb (0,0,1,0.5) # colour of the histogram bars and lines