R/hypothesis-linear-target.R
hypothesis_linear_target_side.RdReads one side of a statement of a hypothesis syntax tree as a
linear combination of the levels of one parameter, \(\sum_l c_l L_l\),
compared with a value by the operator of the side. It is the per-side
reading that hypothesis_linear_target() uses, and it identifies the
combination of levels that a statement is about without a posterior:
statements with identical coefficients refer to the same linear
combination, however their level expressions are written. The coefficients
are not normalized, so a multiple of a combination has other coefficients.
hypothesis_linear_target_side(side, parameter)hypothesis_linear_target_side() returns a list with
operatorthe operator of the side: "=" or "!="
for point sides, and the comparison operator for region sides.
coefficientsa named numeric vector of the coefficients of
the levels divided by divisor, named by level, sorted by level,
without zero coefficients.
numerator_coefficientsthe coefficients of the levels before
the division by divisor.
valuethe value that the combination is compared with, in
the unit of coefficients (the value after moving the constants of
the expressions to it and dividing by divisor).
divisorthe divisor of the expression.
The side is a left or right element of a statement
of a BayesTools_hypothesis_ast (see hypothesis_parse() and
hypothesis_ast_schema()): a point side (=, !=), or a region
side with a simple comparison (<, <=, >, >=). In
a comparison the right expression is subtracted from the left expression.
The expressions are linear in the level references of parameter (for
example f[A]) and numbers: sums and differences, level references
multiplied or divided by numbers, and parentheses. Levels of other
parameters, other terms, and other kinds of sides stop with an error.
The value is the correctly rounded quotient of the statement's constant and
divisor. Numerical loss in the coefficients, or a value that is not finite,
underflows or is subnormal, stops with an error of class
BayesTools_hypothesis_numerical_unavailable, as in
hypothesis_linear_target().
side <- hypothesis_parse("f[A] - 2*f[B] > 0.5")$statements[[1]]$left
hypothesis_linear_target_side(side, "f")
#> $operator
#> [1] ">"
#>
#> $coefficients
#> A B
#> 1 -2
#>
#> $numerator_coefficients
#> A B
#> 1 -2
#>
#> $value
#> [1] 0.5
#>
#> $divisor
#> [1] 1
#>
side <- hypothesis_parse("(f[A] + f[B])/2 = 0")$statements[[1]]$left
hypothesis_linear_target_side(side, "f")
#> $operator
#> [1] "="
#>
#> $coefficients
#> A B
#> 0.5 0.5
#>
#> $numerator_coefficients
#> A B
#> 1 1
#>
#> $value
#> [1] 0
#>
#> $divisor
#> [1] 2
#>