Negative binomial density (mean/size parameterisation), GPU-aware
Source:R/gpuFunctions.R
dnbinom_gpu.RdAs dnbinom (with mu instead of prob),
but runs the log-pmf on the accelerator when x or mu is a
torch tensor and an accelerator is active. Targets the domain SpaNorm
actually uses (non-negative integer x, mu > 0) – outside
that domain this is not a drop-in replacement for stats::dnbinom
(e.g. mu = 0 gives NaN rather than a point mass at 0).
Exposed so downstream packages (e.g. spiDE) computing their own per-gene NB
log-likelihoods reuse the same GPU/CPU-dual-path NB math SpaNorm's own
fitting uses, rather than duplicating it.
Arguments
- x
quantiles (matrix or torch tensor).
- mu
the mean (matrix or torch tensor, same shape as
x).- size
the NB size parameter (
1/dispersion); a length-nrow(x)vector broadcasts row-wise, matching howstats::dnbinomrecycles it.- log
a logical, return the log-density (default
FALSE).