spinn_common 7.1.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
random.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
47#ifndef __RANDOM_H__
48#define __RANDOM_H__
49
50#include <stdint.h>
51#include <stdfix-full-iso.h>
52
76uint32_t mars_kiss32(void);
77
83// 219.9 nanosecs (i.e. 44 ticks) per call on ARM with gcc 4.8.1
84// Also available in custom seed form.
85uint32_t mars_kiss64_simp(void);
86
87// And now... with seeds
88
90typedef uint32_t mars_kiss64_seed_t[4];
91
97
103
116// 294.9 nanosecs (i.e. 59 ticks) per call
117
121void init_WELL1024a_simp(void);
122
125uint32_t WELL1024a_simp(void);
126
127// Versions with seeds
128
131typedef uint32_t WELL1024a_seed_t[33];
132
137
141uint32_t WELL1024a_seed(WELL1024a_seed_t seed);
143
144/* **************************************************
145
146 Non-uniform RNGs
147
148 Being added to all the time, and updated for better speed as
149 fixed-point transcendentals and optimised multiplies become available
150
151****************************************************/
170typedef uint32_t (*uniform_rng)(uint32_t*);
171
179s1615 exponential_dist_variate(uniform_rng uni_rng, uint32_t* seed_arg);
180
186s1615 gaussian_dist_variate(uniform_rng uni_rng, uint32_t* seed_arg);
187
197uint32_t poisson_dist_variate(
198 uniform_rng uni_rng,
199 uint32_t* seed_arg,
200 s1615 lambda);
201
210 uniform_rng uni_rng,
211 uint32_t* seed_arg,
212 u032 exp_minus_lambda);
213
215
216#endif /*__RANDOM_H__*/
uint32_t poisson_dist_variate_exp_minus_lambda(uniform_rng uni_rng, uint32_t *seed_arg, u032 exp_minus_lambda)
Use this version for Poisson with pre-calculated exp(-λ) for speed gain.
Definition random.c:345
void init_WELL1024a_simp(void)
The initialiser function that MUST BE CALLED ONCE before WELLRNG1024a_simp() is used....
Definition random.c:75
uint32_t WELL1024a_seed(WELL1024a_seed_t seed)
The WELL 1024a RNG with custom seed.
Definition random.c:106
uint32_t mars_kiss64_simp(void)
Implementation of Marsaglia JKISS RNG uses 64-bit value and 2x multiplies.
Definition random.c:175
void validate_WELL1024a_seed(WELL1024a_seed_t seed)
MUST USE THIS before passing the seed to WELL1024a_seed() the first time.
Definition random.c:100
uint32_t mars_kiss64_seed(mars_kiss64_seed_t seed)
The Marsaglia KISS 64 RNG with custom seed.
Definition random.c:198
uint32_t(* uniform_rng)(uint32_t *)
The interface type to the uniform RNGs.
Definition random.h:170
uint32_t WELL1024a_seed_t[33]
Seed type for the L'Ecuyer WELL 1024a RNG.
Definition random.h:131
uint32_t mars_kiss64_seed_t[4]
Seed type for the Marsaglia KISS 64 RNG.
Definition random.h:90
uint32_t mars_kiss32(void)
Marsaglia 32-bit KISS generator using no multiplication instructions.
Definition random.c:150
uint32_t poisson_dist_variate(uniform_rng uni_rng, uint32_t *seed_arg, s1615 lambda)
A poisson distributed random variable, given .
Definition random.c:334
s1615 gaussian_dist_variate(uniform_rng uni_rng, uint32_t *seed_arg)
Returns standard Gaussian deviate.
Definition random.c:328
uint32_t WELL1024a_simp(void)
The WELL generator itself.
Definition random.c:86
void validate_mars_kiss64_seed(mars_kiss64_seed_t seed)
Validate seed for Marsaglia KISS 64.
Definition random.c:220
s1615 exponential_dist_variate(uniform_rng uni_rng, uint32_t *seed_arg)
Von Neuman's exponential distribution generator.
Definition random.c:234
Additions to the stdfix.h file to support full Draft ISO/IEC standards compliance.
accum s1615
An alternative name for the signed accum type.
Definition stdfix-full-iso.h:184
unsigned long fract u032
An alternative name for the unsigned long fract type.
Definition stdfix-full-iso.h:196