doc/specify.R

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

## ----setup--------------------------------------------------------------------
library(distionary)

## -----------------------------------------------------------------------------
dst_norm(0, 1)

## -----------------------------------------------------------------------------
dst_gpd(0, 1, 1)

## -----------------------------------------------------------------------------
(hp <- dst_empirical(hp, data = mtcars))

## ---- fig.width = 4, fig.height = 3-------------------------------------------
plot(hp, "cdf", n = 501)

## -----------------------------------------------------------------------------
K <- function(x) dnorm(x, sd = 25)
hp2 <- dst_empirical(hp, data = mtcars, weights = K(disp - 150))
plot(hp, "cdf", n = 1001)
plot(hp2, "cdf", n = 1001, lty = 2, add = TRUE)

## -----------------------------------------------------------------------------
mean(hp2)

## -----------------------------------------------------------------------------
eval_quantile(hp2, at = c(0.05, 0.95))

## -----------------------------------------------------------------------------
1 - variance(hp2) / variance(hp)
vincenzocoia/distionary documentation built on March 5, 2024, 3:13 a.m.