LMMC
Lamina Mathematic core
Toggle main menu visibility
载入中...
搜索中...
未找到
probability_internal.h
浏览该文件的文档.
1
#ifndef LMMC_PROBABILITY_INTERNAL_H
2
#define LMMC_PROBABILITY_INTERNAL_H
3
4
#include <math.h>
5
#include <float.h>
6
#include "
statistics_internal.h
"
7
8
static
inline
int
valid_positive(
lmmc_real_t
value) {
9
return
isfinite(value) && value > 0.0;
10
}
11
12
static
inline
int
valid_probability(
lmmc_real_t
value) {
13
return
isfinite(value) && value > 0.0 && value < 1.0;
14
}
15
16
static
inline
int
student_t_uses_normal_limit(
lmmc_real_t
df) {
17
return
df >= 1.0 / DBL_EPSILON;
18
}
19
20
static
inline
lmmc_status_t
store_density_from_log(
21
lmmc_real_t
log_density,
lmmc_real_t
* out) {
22
lmmc_real_t
result;
23
if
(isnan(log_density) || log_density > log(DBL_MAX)) {
return
LMMC_STATUS_NUMERICAL_FAILURE
; }
24
result = exp(log_density);
25
if
(!isfinite(result)) {
return
LMMC_STATUS_NUMERICAL_FAILURE
; }
26
*out = result;
27
return
LMMC_STATUS_OK
;
28
}
29
30
static
inline
lmmc_status_t
store_probability_result(
31
lmmc_real_t
probability,
lmmc_real_t
* out) {
32
if
(!isfinite(probability) || probability < 0.0 || probability > 1.0) {
return
LMMC_STATUS_NUMERICAL_FAILURE
; }
33
*out = probability;
34
return
LMMC_STATUS_OK
;
35
}
36
37
#endif
lmmc_real_t
double lmmc_real_t
Public and internal LMMC real type.
定义
config.h:28
statistics_internal.h
lmmc_status_t
lmmc_status_t
LMMC 库统一返回的状态码.
定义
status.h:22
LMMC_STATUS_OK
@ LMMC_STATUS_OK
定义
status.h:23
LMMC_STATUS_NUMERICAL_FAILURE
@ LMMC_STATUS_NUMERICAL_FAILURE
定义
status.h:29
src
probability_internal.h
生成于
, 为 LMMC使用
1.18.0