Skip to contents

dist_to_json() writes a distribution as a versioned JSON document: its family and the parameters its constructor takes, numbers bit for bit. dist_from_json() reads it back as an equal distribution of the same class. Mixtures are saved with their components. A custom_distribution cannot be saved: it is an R function.

Usage

dist_to_json(dist)

dist_from_json(text)

Arguments

dist

Any distribution: a parametric severity, a grid_distribution, a sampled distribution or a mixture_distribution.

text

A document written by dist_to_json().

Value

dist_to_json(): a single string. dist_from_json(): the distribution.

Examples

text <- dist_to_json(lognormal(7, 0.5))
d <- dist_from_json(text)
mean(d) == mean(lognormal(7, 0.5))
#> [1] TRUE