sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
threshold_type_fixed_prob.h
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
19#ifndef _THRESHOLD_TYPE_FIXED_PROB_H_
20#define _THRESHOLD_TYPE_FIXED_PROB_H_
21
22#include "threshold_type.h"
23#include <random.h>
24
34
44
45static void threshold_type_initialise(threshold_type_t *state,
47 UNUSED uint32_t n_steps_per_timestep) {
48 state->threshold_value = params->threshold_value;
49 state->prob = params->prob * 0xFFFFFFFF;
50 spin1_memcpy(state->random_seed, params->random_seed, sizeof(mars_kiss64_seed_t));
52}
53
54static void threshold_type_save_state(UNUSED threshold_type_t *state,
56 spin1_memcpy(params->random_seed, state->random_seed, sizeof(mars_kiss64_seed_t));
57}
58
59static inline bool threshold_type_is_above_threshold(
60 state_t value, threshold_type_t *threshold_type) {
61 if (value >= threshold_type->threshold_value) {
62 uint32_t random_number = mars_kiss64_seed(threshold_type->random_seed);
63 return random_number < threshold_type->prob;
64 }
65 return false;
66}
67
68#endif // _THRESHOLD_TYPE_FIXED_PROB_H_
unsigned accum UREAL
Type used for "unsigned real" numbers.
Definition maths-util.h:94
accum REAL
Type used for "real" numbers.
Definition maths-util.h:91
REAL state_t
The type of a state variable.
static uint n_steps_per_timestep
The number of steps to run per timestep.
uint32_t mars_kiss64_seed(mars_kiss64_seed_t seed)
uint32_t mars_kiss64_seed_t[4]
void validate_mars_kiss64_seed(mars_kiss64_seed_t seed)
void spin1_memcpy(void *dst, void const *src, uint len)
static stdp_params params
Configuration parameters.
API for threshold types.
REAL threshold_value
The value of the static threshold.
mars_kiss64_seed_t random_seed
The random seed.
REAL threshold_value
The value of the static threshold.
UREAL prob
The probability of spiking when the threshold has been crossed.
mars_kiss64_seed_t random_seed
The random seed.
uint32_t prob
The probability of spiking when the threshold has been crossed.
Stochastic threshold parameters.
Stochastic threshold configuration.