spinn_common 7.3.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
Macros | Functions | Variables
normal.c File Reference

Support code for random.h. More...

#include <stdint.h>
#include <stdbool.h>
#include <stdfix.h>
#include "stdfix-full-iso.h"
#include "polynomial.h"

Macros

#define abs(x)   (((x) < 0) ? -(x) : (x))
 Absolute value.
 
#define negative(x)   ((x) < 0)
 Is-negative test.
 

Functions

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.
 

Variables

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.
 

Detailed Description

Support code for random.h.

Function Documentation

◆ lo_approx()

static int lo_approx ( unsigned int  approx,
int  x 
)
static

Access to the tail approximation polynomial table evaluation.

Parameters
[in]approxThe number of the approximation (this selects the polynomial patch).
[in]xThe 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]approxThe number of the approximation (this selects the polynomial patch).
[in]xThe 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]approxThe number of the approximation
[in]pThe 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]approxThe number of the approximation.
[in]pThe 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]xA uniformly distributed 16-bit PRNG, in the bottom 16 bits of x.
Returns
A normally distributed int representation of an s16.15 PRNG.

Variable Documentation

◆ offset

int offset[6]
static
Initial value:
= {
7200, 6272, 4608, 2048, 0, 0
}

Offset terms for central_approx()

◆ multiplier

int multiplier[6]
static
Initial value:
= {
32, 16, 8, 6, 6, 0
}

Multiplication factors for central_approx()

◆ leading_terms

int leading_terms[11]
static
Initial value:
= {
98304, 98304, 65536, 65536, 65536, 16, 14, 13, 11, 10, 0
}

Leading terms of the distribution for lo_approx()