inst/doc/diagis.R

## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)

## ----finite_var---------------------------------------------------------------
library("diagis")
set.seed(1)
x <- rgamma(10000, 1, 0.75)
w <- dgamma(x, 2, 1) / dgamma(x, 1, 0.75)
plot(w)
weighted_mean(x, w)

## ----infinite_var-------------------------------------------------------------
set.seed(1)
x_bad <- rgamma(10000, 1, 2)
w_bad <- dgamma(x_bad, 2, 1) / dgamma(x_bad, 1, 2)
plot(w_bad)
weighted_mean(x_bad, w_bad)

## ----weight_plot--------------------------------------------------------------
weight_plot(w)

## ----weight_plot_bad----------------------------------------------------------
weight_plot(w_bad)

Try the diagis package in your browser

Any scripts or data that you put into this service are public.

diagis documentation built on Sept. 8, 2023, 6:13 p.m.