Reads 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)

Arguments

side

one side (left or right) of a statement of a BayesTools_hypothesis_ast, for example hypothesis_parse("f[A] > f[B]")$statements[[1]]$left.

parameter

the parameter whose levels the side references, as a single non-empty string ("f" for f[A]).

Value

hypothesis_linear_target_side() returns a list with

operator

the operator of the side: "=" or "!=" for point sides, and the comparison operator for region sides.

coefficients

a named numeric vector of the coefficients of the levels divided by divisor, named by level, sorted by level, without zero coefficients.

numerator_coefficients

the coefficients of the levels before the division by divisor.

value

the 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).

divisor

the divisor of the expression.

Details

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().

Examples

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
#>