doc/Bernoulli-Events.R

## ---- include = FALSE----------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup, echo = TRUE, message = FALSE---------------------------------
library(nplearn)
library(Rlab)

## ------------------------------------------------------------------------
bern_plot(0.7)

## ------------------------------------------------------------------------
dbern(0, 0.7)

## ------------------------------------------------------------------------
s <- seq(-4,4,.01)

plot(s, dnorm(s), type="l", lwd = 3, ylim = c(0,0.4),
     xlab = "Z Scores", ylab = "Density", main = "Standard Normal Distribution")


## ------------------------------------------------------------------------
pnorm(0.3) - pnorm(0.2)

## ------------------------------------------------------------------------
pnorm(0.3)

s <- seq(-4,4,.01)

plot(s, dnorm(s), type="l", lwd = 3, ylim = c(0,0.4),
     xlab = "Z Scores", ylab = "Density", main = "Standard Normal Distribution")

segments(x0 = 0.3, y0 = 0, x1 = 0.3, y1 = dnorm(0.3))

## ------------------------------------------------------------------------
pnorm(0.3)
pnorm(0.2)
pnorm(0.3) - pnorm(0.2)

s <- seq(-4,4,.01)

plot(s, dnorm(s), type="l", lwd = 3, ylim = c(0,0.4),
     xlab = "Z Scores", ylab = "Density", main = "Standard Normal Distribution")

segments(x0 = 0.2, y0 = 0, x1 = 0.2, y1 = dnorm(0.2))
segments(x0 = 0.3, y0 = 0, x1 = 0.3, y1 = dnorm(0.3))

## ------------------------------------------------------------------------
pbern(1, 0.7)

## ------------------------------------------------------------------------
dbern(0, 0.7) + dbern(1, 0.7)

## ------------------------------------------------------------------------
qnorm(0.6179114)

## ------------------------------------------------------------------------
qbern(0.3, 0.7)

## ------------------------------------------------------------------------
qbern(0.7, 0.7)

## ------------------------------------------------------------------------
qbern(0.5, 0.7)

## ------------------------------------------------------------------------
1 - pnorm(0.3)
pnorm(0.3, lower.tail = FALSE)

1 - pbern(0, 0.7)
pbern(0, 0.7, lower.tail = FALSE)

## ------------------------------------------------------------------------
rnorm(10)
rbern(10, 0.7)
fourthz/nplearn documentation built on April 24, 2023, 1:51 a.m.