package urn

  1. Overview
  2. Docs
Module type
Class type

Input signature of the functor Make.

type t

The type of weights.

val compare : t -> t -> int

A total ordering function over weights. compare x y should return zero if the weights x and y are equal, compare x y should be negative if x is less than y, and compare x y should be positive if x is greater than y.

val zero : t

Weight zero value. It should be the case that forall x, add x zero = x.

val add : t -> t -> t

Weight addition. Should be commutative, associative, etc.

val sub : t -> t -> t

Weight subtraction. It should be the inverse of add, i.e. forall x and y, sub (add x y) y equals x.

val sample : t -> t

Weight sampling function. sample w should produce a value uniformly chosen between zero (inclusive) and w (exclusive). Example: is a suitable sampling function for integer weights.


Innovation. Community. Security.