Module Analysis_and_optimization.Pedantic_dist_warnings

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

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

type dist_info = {
  1. name : 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 : (float * bool) option;
  2. upper : (float * bool) 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 : 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 -> 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 -> bool

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

val value_out_of_range : range -> float -> bool

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

val value_mismatch_constraint : var_constraint -> float -> bool

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

type arg_info =
  1. | Arg of int * string
  2. | Variate
val arg_number : arg_info -> int
val constr_mismatch_message : string -> string -> arg_info -> string -> string
val constr_literal_mismatch_message : string -> string -> arg_info -> string -> string
val constr_mismatch_warning : var_constraint_named -> arg_info -> dist_info -> (Middle.Location_span.t * string) option

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

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

Warning for all uniform distributions with a parameter

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

Warn about all non-Cholesky lkj_corr distributions

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

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

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

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

val distribution_warnings : dist_info Core.Set.Poly.t -> (Middle.Location_span.t * string) Core.Set.Poly.t

Generate the distribution warnings for a program