Learn R Programming

grizbayr (version 1.3.5)

sample_from_posterior: Sample From Posterior

Description

Selects which function to use to sample from the posterior distribution

Usage

sample_from_posterior(
  input_df,
  distribution,
  priors = list(),
  n_samples = 50000
)

Value

A tibble with 2 columns: option_name (chr) and samples (dbl) [long form data].

Arguments

input_df

Dataframe containing option_name (str) and various other columns depending on the distribution type. See vignette for more details.

distribution

String of the distribution name

priors

Optional list of priors. Defaults will be use otherwise.

n_samples

Optional integer value. Defaults to 50,000 samples.

Examples

Run this code
input_df <- tibble::tibble(
   option_name = c("A", "B"),
   sum_clicks = c(1000, 1000),
   sum_conversions = c(100, 120),
   sum_sessions = c(1000, 1000),
   sum_revenue = c(1000, 1500)
)
sample_from_posterior(input_df, "conversion_rate")
sample_from_posterior(input_df, "rev_per_session")

Run the code above in your browser using DataLab