Skip to contents

Returns the first depth bits of the binary expansion of x, which index the nested dyadic Polya-tree partition containing x. The input is first clamped to \([0, 1 - 10^{-15}]\), so values outside the unit interval are silently pulled to the nearest end.

Usage

morie_gh_pt_bits(x, depth)

Arguments

x

numeric scalar in \([0, 1)\)

depth

number of bits (Polya-tree levels) to return

Value

integer vector of length depth of 0/1 bits, most significant first

Examples

morie_gh_pt_bits(x = c(1, 2, 3, 4, 5, 6, 7, 8), depth = 5L)
#> [1] 1 1 1 1 1