Function fillup() concatenates a vector with a ‘fillup’ value to ensure a unit sum; if given a matrix, attaches a column so the rowsums are 1.

Function indep() is the inverse: it removes the final element of a vector, leaving only an independent set.

fillup(x,H=NULL,total=1)
indep(x)

Arguments

x

Numeric vector

H

Object with pnames() attribute, typically of class hyper2 or hyper3, used for names if supplied

total

Total value for probability

Details

Usually you want the total to be one, to enforce the unit sum constraint. Passing total=0 constrains the sum to be zero. This is useful when considering \(\delta p\); see the example at gradient.Rd.

Author

Robin K. S. Hankin

See also

Examples

fillup(c(1/2,1/3))
#> [1] 0.5000000 0.3333333 0.1666667

indep(c(1/2,1/3,1/6))
#> [1] 0.5000000 0.3333333

fillup(indep(icons_maxp))  
#>         NB          L         PB        THC         OA            
#> 0.25230411 0.17364433 0.22458188 0.17011281 0.11068604 0.06867083 
fillup(indep(icons_maxp),icons)
#>         NB          L         PB        THC         OA       WAIS 
#> 0.25230411 0.17364433 0.22458188 0.17011281 0.11068604 0.06867083