Support code for random.h.
More...
#include <stdint.h>
#include <stdbool.h>
#include <stdfix.h>
#include "stdfix-full-iso.h"
#include "polynomial.h"
|
#define | abs(x) (((x) < 0) ? -(x) : (x)) |
| Absolute value.
|
|
#define | negative(x) ((x) < 0) |
| Is-negative test.
|
|
|
static int | lo_approx (unsigned int approx, int x) |
| Access to the tail approximation polynomial table evaluation.
|
|
static int | mid_approx (unsigned int approx, int x) |
| Access to the central approximation polynomial table evaluation.
|
|
static int | tail_approx (unsigned int approx, int p) |
| Access to the tail approximation functions.
|
|
static int | central_approx (unsigned int approx, int p) |
| Access to the central approximation functions.
|
|
int | __norminv_rbits (int x) |
| This function takes a uniformly distributed 16-bit PRNG value, x , and returns a normally distributed s16.15 in int representation.
|
|
|
static int32_t | low_values [] |
| Precalculated extreme values of the normal distribution.
|
|
static int | offset [6] |
| Offset terms for central_approx()
|
|
static int | multiplier [6] |
| Multiplication factors for central_approx()
|
|
static int | leading_terms [11] |
| Leading terms of the distribution for lo_approx()
|
|
static int | polynomials [11][5] |
| Patchwise approximation polynomial terms.
|
|
Support code for random.h.
◆ lo_approx()
static int lo_approx |
( |
unsigned int |
approx, |
|
|
int |
x |
|
) |
| |
|
static |
Access to the tail approximation polynomial table evaluation.
- Parameters
-
[in] | approx | The number of the approximation (this selects the polynomial patch). |
[in] | x | The point at which the function is approximated. |
- Returns
- The corrected value of the polynomial at
x
◆ mid_approx()
static int mid_approx |
( |
unsigned int |
approx, |
|
|
int |
x |
|
) |
| |
|
static |
Access to the central approximation polynomial table evaluation.
- Parameters
-
[in] | approx | The number of the approximation (this selects the polynomial patch). |
[in] | x | The point at which the function is approximated. |
- Returns
- The corrected value of the polynomial at
x
◆ tail_approx()
static int tail_approx |
( |
unsigned int |
approx, |
|
|
int |
p |
|
) |
| |
|
static |
Access to the tail approximation functions.
- Parameters
-
[in] | approx | The number of the approximation |
[in] | p | The point at which the function is approximated. |
- Returns
- Normal value (using algorithm relevant for tail regions)
◆ central_approx()
static int central_approx |
( |
unsigned int |
approx, |
|
|
int |
p |
|
) |
| |
|
static |
Access to the central approximation functions.
- Parameters
-
[in] | approx | The number of the approximation. |
[in] | p | The point at which the function is approximated. |
- Returns
- Normal value (using algorithm relevant for central region)
◆ __norminv_rbits()
int __norminv_rbits |
( |
int |
x | ) |
|
This function takes a uniformly distributed 16-bit PRNG value, x
, and returns a normally distributed s16.15 in int
representation.
Given an 16-bit signed integer value, representing p - 0.5, return the cumulative normal value associated with that probability.
- Parameters
-
[in] | x | A uniformly distributed 16-bit PRNG, in the bottom 16 bits of x . |
- Returns
- A normally distributed int representation of an s16.15 PRNG.
◆ offset
Initial value:= {
7200, 6272, 4608, 2048, 0, 0
}
Offset terms for central_approx()
◆ multiplier
◆ leading_terms
Initial value:= {
98304, 98304, 65536, 65536, 65536, 16, 14, 13, 11, 10, 0
}
Leading terms of the distribution for lo_approx()