title: “Dist normal” author: “Alejandro Medrano” date: “19/6/2020” output: html_document —Objetivo Realizar algunos cálculos de probabilidad haciendo uso de la Distribución Normal Estándard y mediante la función dnorm() Las 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
library(dplyr)
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≤x≤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 μ=0 y σ=1. Se usa pnorm() para encontrar probabilidad acumulada y restando p(x>1.58)=1−p(x≤1.58)
1 - pnorm(c(1.58), mean = 0, sd= 1)
## [1] 0.05705343
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")
Distribución de Probabilidad Normal 1.Para cuando cuando media es diferente de cero 2.Desviación estándard es diferente de 1 Realizar estos ejemplos: … Calcular probabilidades en cualquier distribucion normal, se tiene una distribución en la que: μ=10 y σ=2 ¿Cual es la probabilidad de que la variable aleatoria x este entre 10 y 14?
#primero convertir y luego
pnorm(2, mean=0, sd=1)-pnorm(0, mean=0, sd=1)
## [1] 0.4772499
pnorm(14, mean=10, sd=2)-pnorm(10, mean=10, sd=2)
## [1] 0.4772499
Visualizar la distribución de probabilidad normal estándard para cuando μ=10 y σ=2
plotDist("norm", mean = 10, sd = 2, groups = x > 10 & x < 14, type ="h")
pnorm(14, mean = 10, sd = 2) - pnorm(10, mean = 10, sd = 2)
## [1] 0.4772499
¿Cual es la probabilidad de que sea mayor que 12?
plotDist("norm", mean = 10, sd = 2, groups = x > 12, type ="h")
Opción 1
1 - pnorm(q=12, mean = 10, sd = 2)
## [1] 0.1586553
Opcion 2
pnorm(q=12, mean = 10, sd = 2, lower.tail = FALSE)
## [1] 0.1586553