Module Analysis_and_optimization.Pedantic_dist_warnings

Types and utilities

type compiletime_val =
  1. | Opaque
  2. | Number of Core.float * Core.string
  3. | Param of Core.string * Middle.Expr.Typed.t Middle.Transformation.t
  4. | Data of Core.string

Useful information about an expression. Opaque means we don't know anything.

type dist_info = {
  1. name : Core.string;
  2. loc : Middle.Location_span.t;
  3. args : (compiletime_val * Middle.Expr.Typed.Meta.t) Core.List.t;
}

Info about a distribution occurrences that's useful for checking that distribution properties are met

type range = {
  1. lower : (Core.float * Core.bool) Core.option;
  2. upper : (Core.float * Core.bool) Core.option;
}

Value constraint as a range. The bools are true if the bound is inclusive

type var_constraint =
  1. | Range of range
  2. | Ordered
  3. | PositiveOrdered
  4. | Simplex
  5. | UnitVector
  6. | CholeskyCorr
  7. | CholeskyCov
  8. | Correlation
  9. | Covariance

Value constraint for an argument

type var_constraint_named = {
  1. name : Core.string;
  2. constr : var_constraint;
}

Constraint paired with a name for user messages

val unit_range : var_constraint_named
val exclusive_unit_range : var_constraint_named
val positive_range : var_constraint_named
val nonnegative_range : var_constraint_named
val simplex : var_constraint_named
val ordered : var_constraint_named
val correlation : var_constraint_named
val cholesky_correlation : var_constraint_named
val covariance : var_constraint_named
val cholesky_covariance : var_constraint_named
val bounds_out_of_range : range -> Mir_utils.bound_values -> Core.bool

Check for inconsistency between a distribution argument's value range and the declared bounds of a variable

val transform_mismatch_constraint : var_constraint -> Middle.Expr.Typed.t Middle.Transformation.t -> Core.bool

Check for inconsistency between a distribution argument's constraint and the constraint transformation of a variable

val value_out_of_range : range -> Core.float -> Core.bool

Check for inconsistency between a distribution argument's range and a literal value

val value_mismatch_constraint : var_constraint -> Core.float -> Core.bool

Check for inconsistency between a distribution argument's constraint and a literal value

Argument constraint mismatch warnings

type arg_info =
  1. | Arg of Core.int * Core.string
  2. | Variate
val arg_number : arg_info -> Core.int
val constr_mismatch_message : Core.string -> Core.string -> arg_info -> Core.string -> Core.string
val constr_literal_mismatch_message : Core.string -> Core.string -> arg_info -> Core.string -> Core.string

Return a warning if the argn-th argument doesn't match its constraints

Distribution-specific warnings

val uniform_dist_message : Core.string -> Core.string
val uniform_dist_warning : dist_info -> (Middle.Location_span.t * Core.string) Core.option

Warning for all uniform distributions with a parameter

val lkj_corr_message : Core.string
val lkj_corr_dist_warning : dist_info -> (Middle.Location_span.t * Core.string) Core.option

Warn about all non-Cholesky lkj_corr distributions

val gamma_arg_dist_message : Core.string
val gamma_arg_dist_warning : dist_info -> (Middle.Location_span.t * Core.string) Core.option

Warning particular to gamma and inv_gamma, when A=B<1

Distribution properties table

val distribution_warning : dist_info -> (Middle.Location_span.t * Core.string) Core.List.t

Generate all of the warnings that are relevant to a given distribution

Generate the distribution warnings for a program