Skip to content

Add a sampler for fixed-parameter dist_spec objects #28

Description

@sbfnk

dist.spec can specify a distribution but offers no way to draw samples from one. Callers have to pull the native parameters and dispatch to the base r* functions themselves, duplicating the family and parameter-name knowledge dist.spec already holds:

pars <- get_parameters(x)
switch(get_distribution(x),
  lognormal = rlnorm(n, pars$meanlog, pars$sdlog),
  gamma     = rgamma(n, pars$shape, pars$rate))

Proposal: a sample_dist(x, n) that dispatches on get_distribution(x), and errors if any parameter is a prior rather than a fixed number. Fixed-parameter case only to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions