diff options
| author | Stan Seibert <stan@mtrr.org> | 2011-09-03 09:19:55 -0400 |
|---|---|---|
| committer | Stan Seibert <stan@mtrr.org> | 2011-09-03 09:19:55 -0400 |
| commit | 48550062440c5b7f1479ecbe17fd4b024a90fca2 (patch) | |
| tree | 6b64979c375d98fee4a11fbd4ab4ab86d0507d51 /tests/test_sample_cdf.cu | |
| parent | b8e7b443242c716c12006442c2738e09ed77c0c9 (diff) | |
| download | chroma-48550062440c5b7f1479ecbe17fd4b024a90fca2.tar.gz chroma-48550062440c5b7f1479ecbe17fd4b024a90fca2.tar.bz2 chroma-48550062440c5b7f1479ecbe17fd4b024a90fca2.zip | |
GPU-based sampling from an arbitrary distribition.
The sample_cdf() device function will draw random numbers from an arbitrary
disribution given a cumulative distribution function in the form of
a list of x,y points, beginning with y=0 and ending with y=1. For an
example of how to convert a ROOT histogram to this form, see the unit
test in test_sample_cdf.py
Diffstat (limited to 'tests/test_sample_cdf.cu')
| -rw-r--r-- | tests/test_sample_cdf.cu | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_sample_cdf.cu b/tests/test_sample_cdf.cu new file mode 100644 index 0000000..1401772 --- /dev/null +++ b/tests/test_sample_cdf.cu @@ -0,0 +1,16 @@ +// -*-c++-*- +#include "random.h" + +extern "C" { + +__global__ void test_sample_cdf(int offset, int ncdf, + float *cdf_x, float *cdf_y, float *out) +{ + int id = blockDim.x * blockIdx.x + threadIdx.x; + curandState s; + curand_init(0, id, offset, &s); + + out[id] = sample_cdf(&s, ncdf, cdf_x, cdf_y); +} + +} |
