Added gamma distribution functions.
parent
d5568df7b3
commit
df2448613e
|
@ -733,6 +733,27 @@ namespace nd4j {
|
|||
T temp = val1; val1=val2; val2=temp;
|
||||
};
|
||||
|
||||
// template <typename X, typename Z>
|
||||
// math_def inline Z nd4j_gamma(X a) {
|
||||
//
|
||||
// }
|
||||
template <typename X, typename Z>
|
||||
math_def inline Z nd4j_igamma(X a, X x) {
|
||||
Z aim = nd4j_pow<X, X, Z>(x, a) / (nd4j_exp<X,Z>(x) * std::tgamma(a));
|
||||
auto sum = Z(0.);
|
||||
auto denom = Z(1.);
|
||||
for (auto i = 0; Z(1./denom) > Z(1.0e-6); i++) {
|
||||
denom *= (a + i);
|
||||
sum += nd4j_pow<X, int>(x, i) / denom;
|
||||
}
|
||||
return aim * sum;
|
||||
}
|
||||
|
||||
template <typename X, typename Z>
|
||||
math_def inline Z nd4j_igammac(X a, X x) {
|
||||
return Z(1.) - nd4j_igamma<X, Z>(a, x);
|
||||
}
|
||||
|
||||
#ifdef __CUDACC__
|
||||
namespace atomics {
|
||||
template <typename T>
|
||||
|
|
Loading…
Reference in New Issue