5#ifndef IPPL_NORMAL_DISTRIBUTION_H
6#define IPPL_NORMAL_DISTRIBUTION_H
9#include "Random/Utility.h"
24 return 0.5 * (1 + Kokkos::erf((x - mean) / (stddev * Kokkos::sqrt(2.0))));
37 const T pi = Kokkos::numbers::pi_v<T>;
38 return (1.0 / (stddev * Kokkos::sqrt(2 * pi)))
39 * Kokkos::exp(-(x - mean) * (x - mean) / (2 * stddev * stddev));
53 return mean + 0. * u * stddev;
67 KOKKOS_INLINE_FUNCTION
double operator()(T x,
unsigned int d,
const T* params_p)
const {
68 T mean = params_p[2 * d + 0];
69 T stddev = params_p[2 * d + 1];
70 return ippl::random::normal_cdf_func<T>(x, mean, stddev);
85 KOKKOS_INLINE_FUNCTION
double operator()(T x,
unsigned int d, T
const* params_p)
const {
86 T mean = params_p[2 * d + 0];
87 T stddev = params_p[2 * d + 1];
88 return ippl::random::normal_pdf_func<T>(x, mean, stddev);
100 template <
typename T>
102 KOKKOS_INLINE_FUNCTION
double operator()(T u,
unsigned int d, T
const* params_p)
const {
103 T mean = params_p[2 * d + 0];
104 T stddev = params_p[2 * d + 1];
105 return ippl::random::normal_estimate_func<T>(u, mean, stddev);
109 template <
typename T>
114 KOKKOS_INLINE_FUNCTION
double operator()(T x,
unsigned int d,
115 const T* params_p)
const {
116 T mean = params_p[2 * d + 0];
117 T stddev = params_p[2 * d + 1];
118 return ippl::random::normal_pdf_func<T>(x, mean, stddev);
125 KOKKOS_INLINE_FUNCTION
double operator()(T x,
unsigned int d,
126 const T* params_p)
const {
127 T mean = params_p[2 * d + 0];
128 T stddev = params_p[2 * d + 1];
129 return ippl::random::normal_cdf_func<T>(x, mean, stddev);
135 KOKKOS_INLINE_FUNCTION
double operator()(T u,
unsigned int d,
136 T
const* params_p)
const {
137 T mean = params_p[2 * d + 0];
138 T stddev = params_p[2 * d + 1];
139 return ippl::random::normal_estimate_func<T>(u, mean, stddev);
148 template <
typename T,
unsigned Dim>
KOKKOS_FUNCTION T normal_estimate_func(T u, T mean, T stddev)
An estimator for the initial guess that is used in Newton-Raphson method of Inverste Transfrom Sampli...
Definition NormalDistribution.h:52
KOKKOS_FUNCTION T normal_pdf_func(T x, T mean, T stddev)
Calculate the probability density function (PDF) for a normal distribution.
Definition NormalDistribution.h:36
KOKKOS_FUNCTION T normal_cdf_func(T x, T mean, T stddev)
Calculate the cumulative distribution function (CDF) for a normal distribution.
Definition NormalDistribution.h:23
The class that represents a distribution.
Definition Distribution.h:33
Definition NormalDistribution.h:150
KOKKOS_INLINE_FUNCTION NormalDistribution(const T *par_p)
Constructor for the Normal Distribution class. The constructor takes an array of parameters of normal...
Definition NormalDistribution.h:157
Definition NormalDistribution.h:124
Definition NormalDistribution.h:134
Definition NormalDistribution.h:113
Definition NormalDistribution.h:110
Functor to calculate the cumulative distribution function (CDF) for a normal distribution.
Definition NormalDistribution.h:66
Functor to estimate the initial guess for sampling normal distribution.
Definition NormalDistribution.h:101
Functor to calculate the probability density function (PDF) for a normal distribution.
Definition NormalDistribution.h:84