{"id":19740625,"url":"https://github.com/juliagpu/binomialgpu.jl","last_synced_at":"2025-07-12T21:42:14.646Z","repository":{"id":43866931,"uuid":"348739795","full_name":"JuliaGPU/BinomialGPU.jl","owner":"JuliaGPU","description":"A Julia package for sampling binomial random variates on an nVidia GPU","archived":false,"fork":false,"pushed_at":"2023-08-22T14:41:34.000Z","size":89,"stargazers_count":7,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-20T23:05:56.302Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaGPU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-03-17T14:28:23.000Z","updated_at":"2023-01-07T00:04:46.000Z","dependencies_parsed_at":"2022-08-12T10:50:48.905Z","dependency_job_id":"be333afc-6ed1-401c-8b4e-ee21cdfa8b59","html_url":"https://github.com/JuliaGPU/BinomialGPU.jl","commit_stats":{"total_commits":127,"total_committers":3,"mean_commits":"42.333333333333336","dds":0.09448818897637801,"last_synced_commit":"26bb38b18b1a2b91bba166991e5acaf490aea165"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaGPU%2FBinomialGPU.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaGPU%2FBinomialGPU.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaGPU%2FBinomialGPU.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaGPU%2FBinomialGPU.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaGPU","download_url":"https://codeload.github.com/JuliaGPU/BinomialGPU.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241070051,"owners_count":19904314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T01:22:36.749Z","updated_at":"2025-02-27T22:43:18.634Z","avatar_url":"https://github.com/JuliaGPU.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BinomialGPU\n\n[![Build status](https://badge.buildkite.com/70a8c11259658ad6f836a4981791ed144bac80e65302291d0d.svg?branch=master)](https://buildkite.com/julialang/binomialgpu-dot-jl)\n[![Coverage](https://codecov.io/gh/JuliaGPU/BinomialGPU.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaGPU/BinomialGPU.jl)\n\nThis package exports two functions `rand_binomial` and `rand_binomial!` that produce `CuArrays` with binomially distributed elements, analogous to `CUDA.rand_poisson` and `CUDA.rand_poisson!` for Poisson-distributed ones.\nThe sampling occurs natively on the GPU and is implemented using custom GPU kernels.  \n\nThe performance of this implementation seems to be very competitive with other libraries.\nSampling a 1024x1024 matrix on an RTX2070 GPU: BinomialGPU.jl 0.8ms, PyTorch 11ms, CuPy 18ms, tensorflow 400ms. Benchmarking results for other samplers are very welcome; please open an issue if you find one, especially if it is faster than this package.\n\n\n## Installation\n\nIn a Julia REPL, type `]` to use the built-in package manager and then run:\n\n```\npkg\u003e add BinomialGPU\n```\n\n\n## Usage\n\nSample `CuArrays` with binomial random variates of various dimensions:\n```julia\njulia\u003e using BinomialGPU\njulia\u003e rand_binomial(3, count = 10, prob = 0.5)\n3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:\n 4\n 3\n 7\njulia\u003e rand_binomial(4, 4, count = 10, prob = 0.5)\n4×4 CuArray{Int64, 2, CUDA.Mem.DeviceBuffer}:\n 5  5  6  4\n 5  7  6  7\n 6  4  4  6\n 7  2  4  5\n```\nThe function also supports arrays of parameters of suitable (compatible) sizes:\n```julia\njulia\u003e counts = [5, 10, 20]\njulia\u003e probs = [0.3, 0.4, 0.8]\njulia\u003e rand_binomial(count = counts, prob = probs)\n3-element CuArray{Int64, 1, CUDA.Mem.DeviceBuffer}:\n  0\n  7\n 19\njulia\u003e probs = CUDA.rand(3, 2);\njulia\u003e rand_binomial(count = counts, prob = probs)\n3×2 CuArray{Int64, 2, CUDA.Mem.DeviceBuffer}:\n 3   1\n 4   0\n 3  18\n```\nThe function with exclamation mark samples random numbers in-place:\n```julia\njulia\u003e using CUDA\njulia\u003e A = CUDA.zeros(Int, 4, 4);\njulia\u003e rand_binomial!(A, count = 10, prob = 0.5)\n4×4 CuArray{Int64, 2, CUDA.Mem.DeviceBuffer}:\n 6  4  1  8\n 4  6  6  6\n 4  3  2  4\n 5  7  3  5\n```\nThis also allows for non-standard types to be preserved:\n```julia\njulia\u003e A = CUDA.zeros(UInt16, 4, 4);\njulia\u003e rand_binomial!(A, count = 10, prob = 0.5)\n4×4 CuArray{UInt16, 2, CUDA.Mem.DeviceBuffer}:\n 0x0005  0x0004  0x0003  0x0005\n 0x0006  0x0006  0x0006  0x0003\n 0x0006  0x0005  0x0006  0x0005\n 0x0007  0x0005  0x0006  0x0006\n```\nAlternatively, pass the desired type as the first argument:\n```julia\njulia\u003e rand_binomial(UInt32, 4, 4, count = 10, prob = 0.5)\n4×4 CuArray{UInt32, 2, CUDA.Mem.DeviceBuffer}:\n 0x00000004  0x00000005  0x00000008  0x00000005\n 0x00000003  0x00000007  0x00000005  0x00000005\n 0x00000007  0x00000005  0x00000005  0x00000004\n 0x00000001  0x00000005  0x00000005  0x00000003\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliagpu%2Fbinomialgpu.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliagpu%2Fbinomialgpu.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliagpu%2Fbinomialgpu.jl/lists"}