#Realizar algunos cálculos de probabilidad haciendo uso de la Distribución Normal Estándard y mediante la función dnorm()
#Cargamos librerías
library(mosaic)
## Loading required package: dplyr
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Loading required package: lattice
## Loading required package: ggformula
## Loading required package: ggplot2
## Loading required package: ggstance
##
## Attaching package: 'ggstance'
## The following objects are masked from 'package:ggplot2':
##
## geom_errorbarh, GeomErrorbarh
##
## New to ggformula? Try the tutorials:
## learnr::run_tutorial("introduction", package = "ggformula")
## learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Loading required package: Matrix
## Registered S3 method overwritten by 'mosaic':
## method from
## fortify.SpatialPolygonsDataFrame ggplot2
##
## The 'mosaic' package masks several functions from core packages in order to add
## additional features. The original behavior of these functions should not be affected by this.
##
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
##
## Have you tried the ggformula package for your plots?
##
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
##
## mean
## The following object is masked from 'package:ggplot2':
##
## stat
## The following objects are masked from 'package:dplyr':
##
## count, do, tally
## The following objects are masked from 'package:stats':
##
## binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
## quantile, sd, t.test, var
## The following objects are masked from 'package:base':
##
## max, mean, min, prod, range, sample, sum
#1. Encontar la probabildiad para cuando p(z≤1) con μ=0 y σ=1. Se usa pnorm() para encontrar probabilidad acumulada
pnorm(1, mean = 0, sd= 1)
## [1] 0.8413447
#Visualizar la distribución de probabilidad normal estándard para cuando μ=0 y σ=1
plotDist("norm", mean = 0, sd = 1, groups = x < 1, type = "h")
#2. Encontar la probabilidad para cuando p(0.50≤<≤1.25) con μ=0 y σ=1. Se usa pnorm() para encontrar probabilidad acumulada y restando p(1.25)−p(−0.50)
pnorm(1.25, mean = 0, sd= 1) -pnorm(-0.50, mean = 0, sd= 1)
## [1] 0.5858127
#Visualizar la distribución de probabilidad normal estándard para cuando μ=0 y σ=1
plotDist("norm", mean = 0, sd = 1, groups = x > -0.50 & x < 1.25, type = "h")
#3. Encontar la probabilidad para cuando p(z≥1.58) con μ=0y σ=1. Se usa pnorm() para encontrar probabilidad acumulada y restando p(1.25)−p(−0.50)
1 - pnorm(c(1.58), mean = 0, sd= 1)
## [1] 0.05705343
# ó bien
pnorm(c(1.58), mean = 0, sd= 1, lower.tail= F)
## [1] 0.05705343
#Visualizar la distribución de probabilidad normal estándard para cuando μ=0 y σ=1
plotDist("norm", mean = 0, sd = 1, groups = x > 1.58, type ="h")
#¿Cuál es la probabilidad de que la variable aleatoria X esté entre 10 y 14?
pnorm(2, mean=0,sd=1) - pnorm(0, mean=0,sd=1)
## [1] 0.4772499
#Ó en dado caso
pnorm(14, mean = 10, sd=2) - pnorm(10, mean = 10, sd=2)
## [1] 0.4772499