MCPcopy Create free account
hub / github.com/F-Stack/f-stack / randn

Function randn

dpdk/app/test-bbdev/test_bbdev_perf.c:1529–1544  ·  view source on GitHub ↗

Returns a random number drawn from a normal distribution * with mean of 0 and variance of 1 * Marsaglia algorithm */

Source from the content-addressed store, hash-verified

1527 * Marsaglia algorithm
1528 */
1529static double
1530randn(int n)
1531{
1532 double S, Z, U1, U2, u, v, fac;
1533
1534 do {
1535 U1 = (double)rand() / RAND_MAX;
1536 U2 = (double)rand() / RAND_MAX;
1537 u = 2. * U1 - 1.;
1538 v = 2. * U2 - 1.;
1539 S = u * u + v * v;
1540 } while (S >= 1 || S == 0);
1541 fac = sqrt(-2. * log(S) / S);
1542 Z = (n % 2) ? u * fac : v * fac;
1543 return Z;
1544}
1545
1546static inline double
1547maxstar(double A, double B)

Callers 5

gen_qm8_llrFunction · 0.85
gen_qm6_llrFunction · 0.85
gen_qm4_llrFunction · 0.85
gen_qm2_llrFunction · 0.85
gen_turbo_llrFunction · 0.85

Calls 1

logFunction · 0.50

Tested by

no test coverage detected