weights: Getting and setting the weights of symbols in 'hyper3'...

weightsR Documentation

Getting and setting the weights of symbols in hyper3 objects

Description

Brackets of hyper3 objects contain weighted probabilities; the functionality documented here gets and sets the weights.

Usage

weights.hyper3(object, ...)
as.weight(x)
setweight(x, index, value)
swait(x, ...)

Arguments

x, object

Objects of class hyper3

index, value

Vector of index names and values

...

named arguments corresponding to players to change weights

Details

Suppose we have a hyper3 object:

    > H <- hyper3_nv(list(c(a=1.2), c(b=1), c(a=1.2,b=1,c=1)), powers=c(3,4,-7))
    > H
    log( (a=1.2)^3 * (a=1.2, b=1, c=1)^-7 * (b=1)^4)

And we would like to change the weights of one of the players. We can do this in several ways:

Function setweight() alters the weight of every occurrence of a set of players. It is vectorised, so setweight(H,c("a","b"),88:89) sets the weight of a to 88 and b to 89. Example:

    > H <- hyper3_nv(list(c(a=1.2), c(b=1), c(a=1.2,b=1,c=1)), powers=c(3,4,-7))  # as before
    > setweight(H, "a",1.88)
    log( (a=1.88)^3 * (a=1.88, b=1, c=1)^-7 * (b=1)^4)

Experimental function swait() admits idiom such as swait(H, a=1.88) to accomplish the same thing.

Replacement methods are defined, so “H["a"] <- as.weight(3)” will set the weight of every occurrence of player a to 3. If H is a hyper2 object, it will be coerced to hyper3.

Value

Generally return or deal with hyper3 objects

Author(s)

Robin K. S. Hankin

See Also

hyper2

Examples


H <- hyper3_nv(list(c(a=1.2), c(b=1), c(a=1.2,b=1,c=1)), powers=c(3,4,-7))
H

setweight(H, "b", 1.88)


swait(H, b=1.88) # same thing


swait(H, a=1.1, b=2.2)

H |> swait(b=1.88)


race(letters[1:6]) |> swait(a=1.1, b=1.88)


hyper2 documentation built on June 23, 2026, 5:07 p.m.