| weights | R Documentation |
hyper3 objectsBrackets of hyper3 objects contain weighted probabilities; the
functionality documented here gets and sets the weights.
weights.hyper3(object, ...)
as.weight(x)
setweight(x, index, value)
swait(x, ...)
x, object |
Objects of class |
index, value |
Vector of index names and values |
... |
named arguments corresponding to players to change weights |
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.
Generally return or deal with hyper3 objects
Robin K. S. Hankin
hyper2
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.