Unlike in the Matlab, user can use randn or awgn to adding the white noise to signal.
Now I want to add white noise to signal by using C++.
I only know that in C++ only have the rand() function.
So, can I know how to use C++ to add white noise as how the Matlab are?
Any reference so that I can refer?
I've applied the technique described in the (brilliant!) book "Numerical Recipes in C" to create random numbers with arbitrary probability distributions with success in the past. The book is available freely on the web, and the section describing both the technique AND the generation of Gaussian deviates is here: **broken link removed**
Their function gasdev(...) calls their own random number generator (described earlier in the same chapter **broken link removed**), but you could probably graft in your own if you had a particular favourite
Note that these were added in 2011 -- if your compiler still doesn't support it, upgrade ASAP, it's 2013.
Any of the modern compilers should do: http://isocpp.org/get-started
Alternatively, if you're forced to work with legacy compiler(s), you can also use Boost.Random: http://boost.org/libs/random/
Since the Standard C++ <random> facility is based on the Boost.Random library, it's very easy to reuse the code and translate the examples.
Now i have another problem when i want to get noisy data.
To build noisy data, I aldy added Random Noise with uniform distribution into the E-field data (this is clean data).
But i have problem on how to calculate the SNR between the noisy data and the clean data.
Can i know where can i refer to?