rpg: Polya-Gamma Random Variates using a GPU

Description Usage Arguments Details Value See Also Examples

View source: R/LogitWrapper.R

Description

Generate random variates from the Polya-Gamma distribution on a GPU.

Usage

1
2
rpg(num=1, n=1, z=0.0, batch=32, local=128, staticseed=FALSE,
seed=0, float=0, ptr=NULL, device=0)

Arguments

num

the number of random variates to simulate.

n

shape parameter, a positive integer.

z

parameter associated with tilting.

batch

the number of samples created by each GPU thread

local

the number of threads in a thread-block on a GPU

staticseed

parameter to determine whether to use a static seed or not.

seed

the value of the static seed, if used.

float

parameter to determine whether to use single-precision floating point or double-precision floating point.

ptr

an external pointer to the C structure with the GPU helper variables.

device

if no external pointer is provided to function, we can provide the ID of the device to use.

Details

A random variable X with distribution PG(n,z) is distributed like

X \sim ∑_{k=1}^∞ G(n,1) / ( 2 π^2 (k-1/2)^2 + z^2/2).

The density for X may be derived by exponentially tilting the PG(n,0) density:

p(x|n,z) \propto \exp(-x z^2/2) p(x|n,0).

The GPU implementation is derived from the CPU implementation rpg.devroye from package BayesLogit.

Value

This function returns num Polya-Gamma samples.

See Also

prepare,mlr

Examples

1
random_variates <- rpg(num=100, n=1, z=0.0, device=0)

bayesCL documentation built on May 2, 2019, 3:43 p.m.

Related to rpg in bayesCL...