Evidence.Var
Observation variables.
This module provides a type to describe and type observation variables. Essentially, an observation variable is a named projection function.
module Type : sig ... end
Variable types.
v ?doc ?pp name type' proj
an observation variable with
name
the name or identifier of the variable.type'
the type of the variable.proj
the projection of the variable.pp
a formatter for the variable, defaults to Type.value_pp
label
a label for the variable used in graphical renderingdoc
a documentation string for the variableWarning. For float
types, if you want nan
values to be treated by Dataset
as missing values, you need to use Float
and not Any
or Ordinal
.
Note. Variables have a notion of identity, if you create two variables with the same parameters they will not be deemed equal by equal
.
bool name proj
is v name Bool proj
.
int name proj
is v name Int proj
.
float name proj
is v name Float proj
.
val nominal :
?doc:string ->
?label:string ->
?pp:string fmt ->
name ->
('o -> string) ->
('o, string) t
nominal name proj
is v name Nominal
.
val ordinal :
?doc:string ->
?label:string ->
?pp:'a fmt ->
name ->
('a -> 'a -> int) ->
('o -> 'a) ->
('o, 'a) t
ordinal name compare proj
is v name (Ordinal compare) proj
.
any name proj
is v name Any proj
.
const name type' v
is v name type' (Fun.const v)
.
val doc : ('o, 'a) t -> string
doc var
is the documentation string of var
.
val label : ('o, 'a) t -> string
label var
is the label of var
.
val proj : ('o, 'a) t -> 'o -> 'a
proj var
is the projection of var
.
alter ?doc ?label ?name ?pp var
is var
with the given parameters. The resulting variable is equal to var
.
val map :
?doc:string ->
?label:string ->
?pp:'b fmt ->
('a -> 'b) ->
('o, 'a) t ->
name ->
'b type' ->
('o, 'b) t
map f var name type'
is a new variable derived via f
from var
.
val equal_value : ('o, 'a) t -> 'a -> 'a -> bool
equal_value var
is a comparison function for the values of var
. nan
values are deemed equal.
val compare_value : ('o, 'a) t -> 'a -> 'a -> int
compare_value var
is a comparison function for values of var
. nan
values are deemed equal and lower than any other float value.
val min_value : ('o, 'a) t -> 'a -> 'a -> 'a
min_value var
is a function that determines the minimum for values of var
. On Float
variables this uses Float
.min_num which treats nan
s as missing values.
val max_value : ('o, 'a) t -> 'a -> 'a -> 'a
min_value var
is a function that determines the maximum for values of var
. On Float
variables this uses Float
.max_num which treats nan
s as missing values.
See also Obs
.
The type for variable order.
val order : 'o order list -> 'o -> 'o -> int
order vars
is the lexicographic ascending or descending order of variables vars
of observations. Raises Invalid_argument
if vars
is empty.
val is_na : ('o, float) t -> 'o -> bool
is_na var o
is Float.is_nan (proj var o)
.
val between : 'a -> 'a -> ('o, 'a) t -> 'o -> bool
between min max var o
is true
iff proj var o
is in the range [min
;max
]. This uses compare_value
.
val equal_obs : ('o, 'a) t -> 'o -> 'o -> bool
equal_obs var
tests for equality on variable var
. nan
values are deemed equal.
val compare_obs : ('o, 'a) t -> 'o -> 'o -> int
compare_obs var
tests for equality on variable var
. nan
values are deemed equal.
val min_obs : ('o, 'a) t -> 'o -> 'o -> 'o
min_obs var o0 o1
is the observation with the minimal var
value (either is returned on ties). On Float
variables this uses Float
.min_num which treats nan
s as missing values.
val max_obs : ('o, 'a) t -> 'o -> 'o -> 'o
max_obs var o0 o1
is the observation with the maximal var
value (either is returned on ties). On Float
variables this uses Float
.max_num which treats nan
s as missing values.
equal var0 var1
is true iff var0
and var1
is the same variable.
compare
is a total order on variables compatible with equal
.
for_var_count var
are two variables to access the result of a Dataset.Var.count
dataset.
val cumsum : (float, float) t
cumsum
is the variable for Data
.Var.cum_sum results.
module Prod : sig ... end
Variable products.