TopKSample: Sampler to generate N top-k lists according to p

TopKSampleR Documentation

Sampler to generate N top-k lists according to p

Description

Sampler to generate N top-k lists according to p. A function wrapping to a native C implementation is available as well.

Usage

TopKSample(p, N)
TopKSample.c(p, N)

Arguments

p

Matrix of dimension n*(k+1), n is the number of items (to be ranked) and k is the top elements in the joint ranking. Each column is a multinomial probability vector.

N

The number of samples

Details

A pure R implementation TopKSample and a native C method TopKSample.c are available.

Value

N TopKlists

Note

By default the C implementation is used due to its better performance.

Author(s)

Jie Ding <jding@jimmy.harvard.edu>

Examples

set.seed(1234)
rank.pool <- 1:10
a <- sample(rank.pool, 10)
b <- sample(rank.pool, 10)
c <- sample(rank.pool, 10)
M <- cbind(a, b, c)

TopKSample.c(M, 4)


TopKLists documentation built on Sept. 1, 2022, 5:10 p.m.