Gaussian white noise code in C

  • Permalink
  • submit to reddit
  • Email
  • Follow


Hello all,

I'm in need of a C program which implements the Gaussian white noise
algorithm in C. The program is to accept a binary file as input and
alter it according to the algorithm.
I'm affraid this project must run on Windoze :( 
Thank you in advance

Jess
0
Reply jessex (1) 12/7/2003 9:48:52 AM

See related articles to this posting


"Jess" <jessex@kmfms.com> wrote in message
news:63bbea8b.0312070148.4a07e00@posting.google.com...
> Hello all,
>
> I'm in need of a C program which implements the Gaussian white noise
> algorithm in C. The program is to accept a binary file as input and
> alter it according to the algorithm.
> I'm affraid this project must run on Windoze :(

Jess,

What does Windows have to do with your question?  Presumably you have an
ANSI C compiler that's suitable for generating code that will run on the
usual platforms, no?

What does the "binary file as input" have to do with the question?  Are you
meaning to add the noise to the input data or.....?  If you intend to add
it, then you'll be concerned with scaling the noise to match the intended
application.  This includes the number represenation you'll be using (fixed,
floating, etc.)

Check out:
http://www.dspguru.com/howto/tech/wgn.htm
http://www.mathtools.net/Java/Random_numbers/C_and_C++/

Fred


0
Reply Fred 12/7/2003 7:51:10 PM

On Sun, 07 Dec 2003 09:48:52 +0000, Jess wrote:

> Hello all,
> 
> I'm in need of a C program which implements the Gaussian white noise
> algorithm in C. The program is to accept a binary file as input and
> alter it according to the algorithm.
> I'm affraid this project must run on Windoze :( Thank you in advance
> 


Although I have not tried it, white noise should have a flat spectrum.
You could try setting all values to 1 in a complex array and performing
an inverse FFT on it.

Possibly a tweak or two is in order.

This should be guaranteed white noise !
0
Reply Robin48gx 12/8/2003 12:05:35 AM

Robin48gx <robin48gx@hotmail.com> wrote in message > 
> Although I have not tried it, white noise should have a flat spectrum.
> You could try setting all values to 1 in a complex array and performing
> an inverse FFT on it.
> 
> Possibly a tweak or two is in order.
> 
> This should be guaranteed white noise !

Well, if you do this, you'll get an impulse - autocorrelation of white noise!

Kiran
0
Reply kiranatiisc 12/8/2003 4:21:37 AM

Robin48gx wrote:

> Although I have not tried it, white noise should have a flat spectrum.
> You could try setting all values to 1 in a complex array and performing
> an inverse FFT on it.
> 
> Possibly a tweak or two is in order.
> 
> This should be guaranteed white noise !

This can not be less white noise!!  This is not even noise!!
This is a deterministic signal!!

Maybe (and only *maybe* -- as in, I'm almost sure that it
won't work, but there's a slight chance that it might) if
you set the magnitudes of the FFT to 1, and set the phase
to uniformly distributed random values between -pi and pi...
Maybe you'll get something similar to white noise...

And BTW, how do you expect this to produce *Gaussian* white
noise?  How do you know that it's not going to be uniformly
distributed white noise?

Carlos
--

0
Reply Carlos 12/8/2003 5:49:44 AM

Robin48gx wrote:

> On Sun, 07 Dec 2003 09:48:52 +0000, Jess wrote:
> 
> 
>>Hello all,
>>
>>I'm in need of a C program which implements the Gaussian white noise
>>algorithm in C. The program is to accept a binary file as input and
>>alter it according to the algorithm.
>>I'm affraid this project must run on Windoze :( Thank you in advance
>>
> 
> 
> 
> Although I have not tried it, white noise should have a flat spectrum.
> You could try setting all values to 1 in a complex array and performing
> an inverse FFT on it.
> 
> Possibly a tweak or two is in order.
> 
> This should be guaranteed white noise !

Don't offer guarantees too freely. With one set of phases, it could be
the spectrum of an impulse. With another, of a chirp. Anyhow, summing 12 
to 20 random numbers is easier than a broadband IFFT.

Jerry
-- 
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������

0
Reply Jerry 12/8/2003 4:52:41 PM

What you need to search for is the Box-Muller algorithm. So simpe that even
the meanest programmer should be able to implement it in C.

Nick Felgate

"Jess" <jessex@kmfms.com> wrote in message
news:63bbea8b.0312070148.4a07e00@posting.google.com...
> Hello all,
>
> I'm in need of a C program which implements the Gaussian white noise
> algorithm in C. The program is to accept a binary file as input and
> alter it according to the algorithm.
> I'm affraid this project must run on Windoze :(
> Thank you in advance
>
> Jess


0
Reply Nick 12/12/2003 1:28:42 AM
comp.dsp 19999 articles. 25 followers. Post

6 Replies
1074 Views

Similar Articles

[PageSpeed] 2


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Code for White Gaussian Noise Generator
Hi all, i am stuck up with generating code for white gaussian noise generator with variable output noise and variable variance. I designed the code using Monte-Carlo simulation, x(n+1)=[Bx(n) + u][mod P] and then generating random variables U1 and U2 such that, U1=sqrt(-2lnX1) * cos(2pi X2) U1=sqrt(-2lnX1) * sin(2pi X2) but U1 and U2 are having variance 1 and i need variable variance... can anyone please help with this problem !! thanks, cheers... "Amar" <pathak_amar@hotmail.com> wrote in message news:dp1wy1vnh80u@legacy... > Hi all, > i am st...

Audio jamming using white gaussian noise (matlab code)
Hi anybdy have any idea how can a baseband audio sound can be supressed or jammed using a white gaussian noise and how the result can be shown in Matlab. any help will be appreciated. -Shruti ...

Any C code are valid C++ code?
Since C is a subset of C++, so any C code or C libraries (printf(), scanf(), etc...) are valid C++ code. Is that correct? so even though the whole program is written in C, but with .cpp extension, we still consider as C++ program? Please advise. Thanks jrefactors@hotmail.com wrote: > Since C is a subset of C++ [...] Wrong premise. Wrong conclusion. The answer to your subj is "no". jrefactors@hotmail.com wrote: > Since C is a subset of C++ C is not a subset of C++. C++ has some incompatible changes from C. However, they are compatible enough that a lot of code runs in ...

Adding White Noise (Gaussian Noise) To a Set of 3D Points
Hi All, Could somebody please tell me how I would go about adding white noise to a set of 3d points. I am looking to implement this in c++ so if anybody already has a library or some code snippet as an example it would be much appreiciated. Adam "Adam Hartshorne: > Could somebody please tell me how I would go about adding white noise to > a set of 3d points. Could you please explain what do you mean by adding noise to a set of points? You mean: jitter the coordinates? Or what? Anyway, white noise is an ultralocal distribution, for different points its values are *unc...

Adding White Noise (Gaussian Noise) To A Set Of 3D Points
Hi All, Could somebody please tell me how I would go about adding white noise to a set of 3d points. I am looking to implement this in c++ so if anybody already has a library or some code snippet as an example it would be much appreiciated. Adam Adam Hartshorne wrote: > Could somebody please tell me how I would go about adding white noise > to a set of 3d points. I am looking to implement this in c++ so if > anybody already has a library or some code snippet as an example it > would be much appreiciated. You might want to look in the archives for "Availabe C++ Librar...

How to add white gaussian noise or any other noise in sgnal waveform and normlize it?
In one signal waveform has been normalized by flicker noise as below. f= 0:100; % frequency points fn = 100; % Nyquist rate F= f/fn; % frequency vector M= abs(100./sqrt(f)); % normalized fequency response M= [zeros(1,6),M(6:100)]; % bound from zero frequency [b1,a1] = yulewalk(3,F,M); % generate order=3 filter And then using this b1,a1 co efficient graph has been drawn, I want to do same thing using any other noise like white Gaussian noise or other, how can I do it? I am from IT back ground so don't know well how to play with signals, please help.... Have you looked at...

will subsampled 2-D Gaussian White noise still be white?
Hi, everyone: I generated a 2-D matrix with spatially-uniform Gaussian White noise. Then I fourier transformed the matrix to frequency domain, and sub-sampled it by a factor of 4. Since the the sampling rate is only 1/4 of Nyquist, there will be aliasing in the new matrix. So the new noise distribution is no longer spatially uniform. But will this non-uniform spatial distribution change the power spectrum density of original white noise? Can I say that the resultant noise is not white noise? Thanks a lot! On Sep 1, 5:19=A0am, "sheng fang" <maelstro...@gmail.com> wrot...

mex compiling c++ code but not c code
i get the following error when i try to compile the following code: //hello.c #include <mex.h> void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexPrintf("Hello World!\n"); } / usr/local/MATLAB/R2012a/bin/mex: 1: eval: -c: not found mex: compile of ' "hello.c"' failed. Error using mex (line 206) Unable to complete successfully. when i use the same code but name it as hello.cpp it compiles fine & prints hello world. im using matlab 2012a,ubuntu 12.04,gcc-4.6,g++-4.6 my mex-opts.sh has C...

White Gaussian Noise
I want to add white Gaussian noise of four intensities (i.e. 1%, 2%, 5% and 10% noise to signal ratio) to impact force signals and the acceleration response time histories. Can anyone give me a help? "Rupika Bandara" <rupika23@yahoo.com> wrote in message <hrd378$4e$1@fred.mathworks.com>... > I want to add white Gaussian noise of four intensities (i.e. 1%, 2%, 5% and 10% noise to signal ratio) to impact force signals and the acceleration response time histories. Can anyone give me a help? if you have communications toolbox: doc awgn doc wgn On Apr 30, 11:03=A0...

Having C code looking like C++ code
Hi, I've been asked in a job interview how to make C code look like C++ code, and honestly I didn't know what to answer because I have never really done a lot of C. Now, I've been searching around the web about web sites that talk about this subject, but I've had no luck. Can anyone point me to some web site about this subject? Thanks a lot! Fronsac wrote: > Hi, > I've been asked in a job interview how to make C code look like C++ > code, and honestly I didn't know what to answer because I have never > really done a lot of C. Now, I've been s...

calling Matlab code from C/C++ code
Hi, I am learning to call Matlab code from C/C++ code. Here are my questions (1)are using Matlab engine and converting Matlab code into a C or C++ shared library the only two ways? (2) what's the difference between these two methods? Advantages and disadvantages? In what case use which method is better? Thanks and regards! On Mon, 03 Aug 2009 10:33:00 -0400, Tim <timlee126@yahoo.com> wrote: > Hi, > I am learning to call Matlab code from C/C++ code. Here are my > questions > > (1)are using Matlab engine and converting Matlab code into a C or C++ > shared library...

source code browser for C / C++ code
hi, which is the best source code browser for c / c++ source code... on windows.. better if its free download... i tried source navigator 5.1.4 and 5.2b2.. but it is crashing while parsing the c++ source code... i have a huge source code to dig into to fix bugs... pls help... -- rahul Rahul wrote: > which is the best source code browser for c / c++ source code... on > windows.. [..] Why don't you ask in a Windows programming newsgroup? V -- Please remove capital 'A's when replying by e-mail I do not respond to top-posted replies, please don't ask * Victor Baza...

convert c# code to c++/c
hi people, Im stuck with a problem. I want to convert the following C# code to c++/c im trying to convert it line by line by myself. but still cant do away with some errors.. kindly help here is my code.. Imports System.Net Imports System.Net.Sockets Imports System.IO Public Class Form1 Private Client As New UdpClient(4370) 'Local machine uses UDP and port 4370 Private ZkDevice As New IPEndPoint(IPAddress.Parse("192.168.1.201"), 4370) 'Address of Device and port Private SessionID As UInt16 'ID of session. Each session have a unique ID ...

link c code with c++ code using g++
I compile one object using gcc and another using g++ then i use g++ to link the to objects and i get that the fuctions of the c object are unknown references for the c++ object. can any body explain me how can i link c code with c++ code ? i tried extern "C" but seems that that doesn't compile with g++ thanks jorge Compile all your source code (both C and C++) using g++ and use the extern C feature to turn off name mangling for the C functions. HTH, Ravi. J.Artieda wrote: > I compile one object using gcc and another using g++ then i use g++ to link > the to objects an...

Matlab face detection code to c/c++ code
hello guys... I am in urgent need of something which can change my MATLAb code to C or C++ code. I have to run this C, c++ code in Code composer studio and feed the program into DSP emulator EVDM642. Code composer studio does not support MATLAB... So, its important to convert the code into C or C++.. This is my semester project and I have to give the presentation on 18th november...or else I will be failed.. Please help me guys....Tell e something which changes MATLAb to C/C++. Thanx in advance. On 16 Nov., 05:42, "Tarun " <tarunsa...@gmail.com> wrote: > hello guys... >...

How to transfer matlab codes into visual c++ or c codes?
Hi, Folks I have written some matlab functions (Matlab 6.5), and I want to change them into visual c++ or c codes then create a visual c++ project to use the generated c++ or c codes.(visual c++ 6.0). Could anyone give me the full instructions on how to deal with it because I have met some unresolved external symbol problems when linking (use visual c++ 6.0). Have I missed to include some lib files? Thanks. Hi, Suppose you have an M-file mySquare.m: function y = mySquare(x) y = x*x ; You'll create a dll file by using the command: mcc -t -L C -W lib:mySquarelib -T link:lib mySquare.m...

How to do this in C++ (C code)
in C, I have this : #define doStuff(var) func(var##_1, var##_2) void func(int v, int v2) { printf("%d, %d\n", v, v2); } int main() { int myvar_1 = 1; int myvar_2 = 2; doStuff(myvar); // ... } I want to do a class to encapsulate the func, but how can I do the same thing with a class ? I would like to do something like this : int myvar_1 = 1; int myvar_2 = 2; CMyClass c; c.doStuff(myvar); How can I do that ? Thanks for your help, S. timor.super@gmail.com wrote: > in C, I have this : > > #define doStuff(var) func(var##_1, var##_2) > > void func(int v, int...

C++ implementation for C API ---- converting legacy C code to C++
[My apologies if this LONG posting is off-topic] In this day and age, you never say no to any work that is thrown at you ---- so when I was offered this short-term contract to convert legacy C code to C++, I did not say no. Personally I believed that it was a somewhat futile exercise since one of the main requirements was for the existing API (a functional interface written in C) to remain the same. I would have much rathered that the mandate be ab-initio, but that was not the case here. My client had a bad experience with OO, and they wanted to re-tread this path very very carefully. The...

C++ code with C-style interface for a library to be used in C++ and C?
Hi! I have a question about building and then using libraries containing C++ code. Let's say I have some C++ code and a .cpp file with 1 function that uses some other C++ code / classes etc... Also, any possible exception is handled within the function itself. In code: MyModule.h ---------- #ifndef MYMODULE_H #define MYMODULE_H extern int Test(float inParam1,float inParam2,float* outResult); #endif // #ifndef MYMODULE_H MyModule.cpp ------------ #include "MyModule.h" #include "MyClasses.h" // contains MyClassA and MyClassB int Test(float inParam1,float inParam2,...

Re: source code browser for C / C++ code 491176
On Wed, 06 Feb 2008 20:13:34 -0600, Alex wrote: > On Feb 6, 2:02 pm, Le Chaud Lapin <jaibudu...@gmail.com> wrote: >> On Feb 6, 4:12 am, Thomas Lehmann <t.lehm...@rtsgroup.net> wrote: >> >> > > IMHO, Visual Studio. >> >> > > Visual Studio 2008 Express Edition is free: >> > > :http://tinyurl.com/2h9yma >> >> > Rahul meant "source code browser" - not IDE, did you? > > If Rahul wants to get a grip of a large codebase, IDE with source > browser is no doubt better than running doxygen on it. Visu...

Many Fortran code! How to call Fortran code from C/C++?
Hi all, As a C/C++ programmer, there are a few reasons to use Fortran: (1) Fortran is very similar to Matlab and easy to port; (2) Fortran has support of complex numbers and vectorized numbers and the operations in Fortran are naturally element-wise, operating on a whole vector. (3) There are many scientific codes are in Fortran. ------------- So how do I call Fortran program from my C program? I am using MSVS. NET 2003, VisualC++ and Intel C++ therein, and also the Intel Visual Fortran therein. To give an example, I want to call a Fortran program from C++, which is in its bare form, it ...

question about white gaussian noise
does additive white gaussian noise only change the amplitude of a signal or does it change both amplitude and phase? "bamse" <bamse@kyllingen.dkkkk> wrote in message news:<6BEnc.4$NS3.3@news.get2net.dk>... > does additive white gaussian noise only change the amplitude of a signal or > does it change both amplitude and phase? There are two ways of looking at Gaussian noise: Time domain: Random numbers are drawn from a Gaussian distribution and added to the samples in the signal, thus "changing the amplitude" of the individual samples. Frequency domain...

additive white Gaussian noise
Hello all please help me ; If I want to generate the following signal x= u*h ; y= x+ n ; u=[1 1 1 1 -1 -1 -1 -1 ] ; h= random('rayl',1,8 ) ; I want the signal to noise ration to be 5 dB ; I am generating 8 random Rayleigh fading envelopes and multiplying them by 1 or -1 according the the Hypothesis ( In wireless sensor Network ) ; Will I have to use var(x) ... to calculate the signal power and after that calculating the required noise power ? In some references they use the following formula : SNR= mean(x)/ std(n) In the paper which I am trying to implem...

Re: source code browser for C / C++ code 219058
Thomas Lehmann wrote: > - And most effort is required for C++: This language is complex and the > most high end products are not able to provide every required feature. > Two good examples: Programming Java I found myself surprised working with > eclipse because everything from code analysis, to parallel debugging, > metric and unit-testing is covered by one product but wait ... > you have to install some plugins but then it's quite fine ... > Same for C#. Working with Visual Studio and C# you will have a similar > environment! Unfortu...