package tezos-protocol-alpha

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

S is the module type of a module allowing to construct samplers based on the alias method.

type mass

mass is the type in which finite measures take their values (see Mass module type).

type 'a t

'a t is the type of auxilliary data for sampling from a given distribution.

val create : ('a * mass) list -> 'a t

create measure constructs auxilliary data to sample from measure after normalization. Complexity: O(n).

It is assumed that the measure is positive. measure can contain zero mass elements: those are removed in a pre-processing step. The total mass of the measure should be strictly positive.

  • raises Invalid_argument

    if measure contains negative mass elements or if it contains only zero mass elements.

val sample : 'a t -> (int_bound:int -> mass_bound:mass -> int * mass) -> 'a

sample auxdata rand creates a sampler from auxdata that follows the distribution associated to the measure specified when creating the auxdata. The parameter rand is a random sampler for the two random values used by the sampling method. The first bound is at most the length of the list passed to create when creating auxdata. The second bound is at most the sum of all items in the list passed to create.

val encoding : 'a Data_encoding.t -> 'a t Data_encoding.t

encoding e constructs an encoding for 'a t given an encoding for 'a.