Spike
Loading...
Searching...
No Matches
WhiteNoiseSignal.h
1#ifndef SPIKE_WHITENOISESIGNAL_H
2#define SPIKE_WHITENOISESIGNAL_H
3
4#include <complex>
5#include <random>
6#include <string>
7#include <vector>
8
10#include "Spike/TimeFrame/TimeFrame.h"
11
12namespace Spike {
13
18class WhiteNoiseSignal : public Signal {
19private:
20 double alpha;
21 double f_low;
22 double f_high;
23
24 std::random_device rd;
25 std::mt19937 generator;
26 std::normal_distribution<double> dist;
27
28 std::vector<std::complex<double>>
29 frequencies;
30
31public:
39 WhiteNoiseSignal(double alpha, double f_low, double f_high,
40 const TimeFrame &time_frame);
41
47 WhiteNoiseSignal(const std::string &input_file, const TimeFrame &time_frame);
48
52 void calculate_signal();
53
59 [[nodiscard]] double signal(double t) const;
60
65 void set_alpha(double alpha_new) { alpha = alpha_new; };
66
71 [[nodiscard]] const std::vector<double> &get_values() const {
72 return signal_values;
73 };
74
79 [[nodiscard]] const std::vector<std::complex<double>> &
81 return frequencies;
82 };
83
88 [[nodiscard]] double get_alpha() const { return alpha; };
89
94 [[nodiscard]] double get_variance() const {
95 return 2. * (f_high - f_low) * alpha;
96 };
97
102 void print(std::ostream &out) const override {
103 out << "WhiteNoiseSignal(alpha: " << alpha << ", f_low: " << f_low
104 << ", f_high: " << f_high << ")";
105 }
106};
107
108} // namespace Spike
109
110#endif // SPIKE_WHITENOISESIGNAL_H
An abstract base class for signals.
Definition Signal.h:20
const TimeFrame & time_frame
reference to time frame
Definition Signal.h:22
std::vector< double > signal_values
array containing the signal values
Definition Signal.h:23
A time frame with discrete time steps.
Definition TimeFrame.h:13
Implements a band limited white gaussian noise get_value.
Definition WhiteNoiseSignal.h:18
const std::vector< double > & get_values() const
Returns the white noise signal vector.
Definition WhiteNoiseSignal.h:71
double get_variance() const
Returns the variance.
Definition WhiteNoiseSignal.h:94
double signal(double t) const
Return get_value, i.e. white noise at time t.
Definition WhiteNoiseSignal.cpp:89
double get_alpha() const
Returns the amplitude.
Definition WhiteNoiseSignal.h:88
WhiteNoiseSignal(double alpha, double f_low, double f_high, const TimeFrame &time_frame)
Construct WhiteNoiseSignal from parameters.
Definition WhiteNoiseSignal.cpp:17
void set_alpha(double alpha_new)
Sets the amplitude for the white noise signal.
Definition WhiteNoiseSignal.h:65
void calculate_signal()
Generate the white noise, i.e. fill the signal_values.
Definition WhiteNoiseSignal.cpp:46
const std::vector< std::complex< double > > & get_frequencies() const
Returns the frequencies.
Definition WhiteNoiseSignal.h:80
void print(std::ostream &out) const override
Prints white noise signal to out stream.
Definition WhiteNoiseSignal.h:102