12 static std::vector<double> random_real_part;
13 static std::vector<double> random_imag_part;
15 if (random_real_part.size()!=spec.size()){
16 random_real_part.resize(spec.size(),0);
17 random_imag_part.resize(spec.size(),0);
18 for (
unsigned int i=0;i<spec.size();i++){
19 random_real_part.at(i) = rng->normal(0,1);
20 random_imag_part.at(i) = rng->normal(0,1);
24 const int shift1 = rng->uniform(0,random_real_part.size());
26 const int step = 1./ replace;
27 for (
int i =shift1; i<shift1 +
int(spec.size()); i+=
step){
28 if (i<
int(spec.size())){
29 random_real_part.at(i) = rng->normal(0,1);
30 random_imag_part.at(i) = rng->normal(0,1);
32 random_real_part.at(i-spec.size()) = rng->normal(0,1);
33 random_imag_part.at(i-spec.size()) = rng->normal(0,1);
38 const int shift = rng->uniform(0,random_real_part.size());
42 for (
int i=shift;i<
int(spec.size());i++){
43 const double amplitude = spec.at(i-shift) * sqrt(2./3.1415926);
44 noise_freq.at(i-shift).real(random_real_part.at(i) * amplitude);
45 noise_freq.at(i-shift).imag(random_imag_part.at(i) * amplitude);
47 for (
int i=0;i<shift;i++){
48 const double amplitude = spec.at(i+
int(spec.size())-shift) * sqrt(2./3.1415926);
49 noise_freq.at(i+
int(spec.size())-shift).real(random_real_part.at(i) * amplitude);
50 noise_freq.at(i+
int(spec.size())-shift).imag(random_imag_part.at(i) * amplitude);
std::shared_ptr< Interface > pointer
WireCell::Waveform::realseq_t generate_waveform(const std::vector< float > &spec, IRandom::pointer rng, double replace=0.02)