Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

bayesCL (version 0.0.1)

rpg: Polya-Gamma Random Variates using a GPU

Description

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

Usage

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.

Value

This function returns num Polya-Gamma samples.

Details

A random variable X with distribution PG(n,z) is distributed like Xk=1G(n,1)/(2π2(k1/2)2+z2/2). The density for X may be derived by exponentially tilting the PG(n,0) density: p(x|n,z)exp(xz2/2)p(x|n,0). The GPU implementation is derived from the CPU implementation rpg.devroye from package BayesLogit.

See Also

prepare,mlr

Examples

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

Run the code above in your browser using DataLab