sPyNNaker neural_modelling  development
rng.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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 
21 #include "rng.h"
22 #include <spin1_api.h>
23 #include <normal.h>
24 #include "common_mem.h"
25 
26 uint32_t rng_generator(rng_t *rng) {
27  return mars_kiss64_seed(rng->seed);
28 }
29 
31  return exponential_dist_variate(mars_kiss64_seed, rng->seed);
32 }
33 
34 accum rng_normal(rng_t *rng) {
35  uint32_t random_value = rng_generator(rng);
36  return norminv_urt(random_value);
37 }
Utility functions for working with memory.
accum rng_exponential(rng_t *rng)
Generate an exponentially-distributed random number.
Definition: rng.c:30
accum rng_normal(rng_t *rng)
Generate an normally-distributed random number.
Definition: rng.c:34
uint32_t rng_generator(rng_t *rng)
Generate a uniformly-distributed random number.
Definition: rng.c:26
Random number generator interface.
The Random number generator parameters.
Definition: rng.h:30
static uint32_t rng(void)
Random number generation for the Poisson sources. This is a local version for speed of operation.