DSPRelated.com
Forums

signal generator with uniformly distribution and specific self correlation function and spectrum

Started by broc...@gmail.com December 5, 2007
dear everybody:
      Please kindly do me a favor.
On Dec 6, 2:35 am, "broc...@gmail.com" <broc...@gmail.com> wrote:
> dear everybody: > Please kindly do me a favor.
sorry for mis-send. I try to write a random signal generator which should satisfy following requirements: 1. uniformly distribution on [0, 1] 2. the self correlation function has a single peak with width of several ( 5~7 ) samples on the center 3. spectrum has energy only on low frequency I don't know how to construct it, and I think it has been said clearly. Any suggession is welcome Thanks very much. BR. wayne
On Dec 5, 1:54 pm, "broc...@gmail.com" <broc...@gmail.com> wrote:
> On Dec 6, 2:35 am, "broc...@gmail.com" <broc...@gmail.com> wrote: > > > dear everybody: > > Please kindly do me a favor. > > sorry for mis-send. > I try to write a random signal generator which should satisfy > following requirements: > 1. uniformly distribution on [0, 1] > 2. the self correlation function has a single peak with width of > several ( 5~7 ) samples on the center > 3. spectrum has energy only on low frequency > > I don't know how to construct it, and I think it has been said > clearly.
what you are trying to do is design a random number generator (we'll call it "noise") with specified p.d.f. (uniform) and power spectrum (or auto-correlation). doing both is hard. if the noise p.d.f. is "normal" (a.k.a. "gaussian"), and the spectrum is white (or, at least, known), you can design a LTI filter that will filter the noise so that the output has the spectrum you seek. phase response in this filter does not matter, only the magnitude response as a function of frequency. the output will also be gaussian. in fact, even if the input is not gaussian, the output will approach gaussian as the order of the filter increases because of the central limit theorem. if spectrum is not a spec, you can take a random number with known p.d.f. (call it "X") and run it through a memoryless and invertable non-linear function (Y = f(X)) and get a random number (call it "Y") with a different p.d.f. where the p.d.f's are related as so: p_Y(y) = p_X(x) * |f'(x)|^(-1) or p_Y(y) = p_X( g(y) ) * |f'( g(y) )|^(-1) where y = f(x) = f( g(y) ) and x = g(y) = g( f(x) ) so g() is the inverse function of f(). p_Y(y) and p_X(x) are the p.d.f's of the output and input random numbers, Y and X, respectively. the spectrum of the output is left unspecified, but i think a pretty good case can be made that if the input to the non- linear function (X) is white (that is, the correlation between samples is zero), the same can be said for the output of the non-linear function Y. now, this is not a proof and i cannot guarantee it will always work, but i would suggest to first generate a white and gaussian RN (add together a dozen independent uniform RNs, that's good enough, or run a uniform RN through a non-linearity to get something approximating gaussian). then filter that gaussian through the necessary filter to get you a guassian signal, but with the spectrum (or autocorrelation) that you seek. then take that colored, gaussian RN and run that through a non-linearity to get the p.d.f. that you seek. it will get you close. perhaps after creating this generator, you can generate a few billion samples overnight and run statistical analysis on it to see if you got the spectrum you really want (in case the non- linearity changed it). the p.d.f. should be exactly correct. r b-j
On Dec 5, 2:38 pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Dec 5, 1:54 pm, "broc...@gmail.com" <broc...@gmail.com> wrote: > > > On Dec 6, 2:35 am, "broc...@gmail.com" <broc...@gmail.com> wrote: > > > > dear everybody: > > > Please kindly do me a favor. > > > sorry for mis-send. > > I try to write a random signal generator which should satisfy > > following requirements: > > 1. uniformly distribution on [0, 1] > > 2. the self correlation function has a single peak with width of > > several ( 5~7 ) samples on the center > > 3. spectrum has energy only on low frequency > > > I don't know how to construct it, and I think it has been said > > clearly. > > what you are trying to do is design a random number generator (we'll > call it "noise") with specified p.d.f. (uniform) and power spectrum > (or auto-correlation). doing both is hard. > > if the noise p.d.f. is "normal" (a.k.a. "gaussian"), and the spectrum > is white (or, at least, known), you can design a LTI filter that will > filter the noise so that the output has the spectrum you seek. phase > response in this filter does not matter, only the magnitude response > as a function of frequency. the output will also be gaussian. in > fact, even if the input is not gaussian, the output will approach > gaussian as the order of the filter increases because of the central > limit theorem. > > if spectrum is not a spec, you can take a random number with known > p.d.f. (call it "X") and run it through a memoryless and invertable > non-linear function (Y = f(X)) and get a random number (call it "Y") > with a different p.d.f. where the p.d.f's are related as so: > > p_Y(y) = p_X(x) * |f'(x)|^(-1) > > or > > p_Y(y) = p_X( g(y) ) * |f'( g(y) )|^(-1) > > where y = f(x) = f( g(y) ) and x = g(y) = g( f(x) ) > > so g() is the inverse function of f(). p_Y(y) and p_X(x) are the > p.d.f's of the output and input random numbers, Y and X, > respectively. the spectrum of the output is left unspecified, but i > think a pretty good case can be made that if the input to the non- > linear function (X) is white (that is, the correlation between samples > is zero), the same can be said for the output of the non-linear > function Y. > > now, this is not a proof and i cannot guarantee it will always work, > but i would suggest to first generate a white and gaussian RN (add > together a dozen independent uniform RNs, that's good enough, or run a > uniform RN through a non-linearity to get something approximating > gaussian). then filter that gaussian through the necessary filter to > get you a guassian signal, but with the spectrum (or autocorrelation) > that you seek. then take that colored, gaussian RN and run that > through a non-linearity to get the p.d.f. that you seek. > > it will get you close. perhaps after creating this generator, you can > generate a few billion samples overnight and run statistical analysis > on it to see if you got the spectrum you really want (in case the non- > linearity changed it). the p.d.f. should be exactly correct. > > r b-j
Does the nonlinear function need to be symmetric too? Otherwise couldn't it potentially create a DC bias in the output? John
John wrote:

   ...

> Does the nonlinear function need to be symmetric too? Otherwise > couldn't it potentially create a DC bias in the output?
It needs to be symmetric if you don't want DC. It needs to be asymmetric if you do want DC. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Dec 5, 5:36 pm, Jerry Avins <j...@ieee.org> wrote:
> John wrote: > > ... > > > Does the nonlinear function need to be symmetric too? Otherwise > > couldn't it potentially create a DC bias in the output? > > It needs to be symmetric if you don't want DC. It needs to be asymmetric > if you do want DC. >
well, that all depends on what the input p.d.f. is. if the input p.d.f. is symmetric about 0, then its mean (DC) is 0 and, if you want no DC in the output, the mean, determined from the p.d.f. needs to be zero, but it does not have to be symmetric. even if the nonlinear function had (odd) symmetry, if the p.d.f. going in had a non-zero mean (a DC component), the p.d.f. coming out would not have to have the same non-zero mean. wouldn't that be a DC bias? so, as far as i can tell, symmetry of the non-linear mapping is neither necessary nor sufficient to preclude a DC bias (or a shift in the mean of the p.d.f.). r b-j
robert bristow-johnson wrote:
> On Dec 5, 5:36 pm, Jerry Avins <j...@ieee.org> wrote: >> John wrote: >> >> ... >> >>> Does the nonlinear function need to be symmetric too? Otherwise >>> couldn't it potentially create a DC bias in the output? >> It needs to be symmetric if you don't want DC. It needs to be asymmetric >> if you do want DC. >> > > well, that all depends on what the input p.d.f. is. if the input > p.d.f. is symmetric about 0, then its mean (DC) is 0 and, if you want > no DC in the output, the mean, determined from the p.d.f. needs to be > zero, but it does not have to be symmetric. > > even if the nonlinear function had (odd) symmetry, if the p.d.f. going > in had a non-zero mean (a DC component), the p.d.f. coming out would > not have to have the same non-zero mean. wouldn't that be a DC bias? > > so, as far as i can tell, symmetry of the non-linear mapping is > neither necessary nor sufficient to preclude a DC bias (or a shift in > the mean of the p.d.f.).
I thought that the PDF you prescribed as input was uniform. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
On Dec 5, 8:44 pm, Jerry Avins <j...@ieee.org> wrote:
> robert bristow-johnson wrote: > > On Dec 5, 5:36 pm, Jerry Avins <j...@ieee.org> wrote: > >> John wrote: > > >> ... > > >>> Does the nonlinear function need to be symmetric too? Otherwise > >>> couldn't it potentially create a DC bias in the output? > >> It needs to be symmetric if you don't want DC. It needs to be asymmetric > >> if you do want DC. > > > well, that all depends on what the input p.d.f. is. if the input > > p.d.f. is symmetric about 0, then its mean (DC) is 0 and, if you want > > no DC in the output, the mean, determined from the p.d.f. needs to be > > zero, but it does not have to be symmetric. > > > even if the nonlinear function had (odd) symmetry, if the p.d.f. going > > in had a non-zero mean (a DC component), the p.d.f. coming out would > > not have to have the same non-zero mean. wouldn't that be a DC bias? > > > so, as far as i can tell, symmetry of the non-linear mapping is > > neither necessary nor sufficient to preclude a DC bias (or a shift in > > the mean of the p.d.f.). > > I thought that the PDF you prescribed as input was uniform. >
but it wouldn't have to be zero mean. most random number generators generate a non-negative, uniformly distributed pseudo-random integer that is from 0 to 2^(N-1) - 1 where N is the number of bits in the word (and each RN is independent, so it's white up to Nyquist). at least that's what rand() does (gcc stdlib). but, of course, it's easy to unbias that by subtracting 2^(N-2), but you *could* just run the raw (biased) RN into the non- linear mapping, and if it's defined right, get a zero-mean, virtually Gaussian RN coming out. but, my main point is that symmetry (about 0) of a p.d.f. *will* guarantee that it is zero mean, but you can create a zero mean out of any non-symmetrical p.d.f. by first calculating the mean and then subtracting that mean from the RN. the result is a p.d.f. that has zero mean, but is not symmetrical. also, if the RN going into a non-linear function with odd symmetry was a zero-mean RN, but with an assymetrical p.d.f., it's not necessarily true that what comes out will be zero mean. but, this is true: RN with symmetrical p.d.f. about 0 (which is necessarily zero mean) goes into a function that has odd symmetry --> the result will be another RN with a symmetrical p.d.f. about 0 (which means it also is zero mean). that is true. r b-j
On Dec 6, 3:38 am, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On Dec 5, 1:54 pm, "broc...@gmail.com" <broc...@gmail.com> wrote: > > > On Dec 6, 2:35 am, "broc...@gmail.com" <broc...@gmail.com> wrote: > > > > dear everybody: > > > Please kindly do me a favor. > > > sorry for mis-send. > > I try to write a random signal generator which should satisfy > > following requirements: > > 1. uniformly distribution on [0, 1] > > 2. the self correlation function has a single peak with width of > > several ( 5~7 ) samples on the center > > 3. spectrum has energy only on low frequency > > > I don't know how to construct it, and I think it has been said > > clearly. > > what you are trying to do is design a random number generator (we'll > call it "noise") with specified p.d.f. (uniform) and power spectrum > (or auto-correlation). doing both is hard. > > if the noise p.d.f. is "normal" (a.k.a. "gaussian"), and the spectrum > is white (or, at least, known), you can design a LTI filter that will > filter the noise so that the output has the spectrum you seek. phase > response in this filter does not matter, only the magnitude response > as a function of frequency. the output will also be gaussian. in > fact, even if the input is not gaussian, the output will approach > gaussian as the order of the filter increases because of the central > limit theorem. > > if spectrum is not a spec, you can take a random number with known > p.d.f. (call it "X") and run it through a memoryless and invertable > non-linear function (Y = f(X)) and get a random number (call it "Y") > with a different p.d.f. where the p.d.f's are related as so: > > p_Y(y) = p_X(x) * |f'(x)|^(-1) > > or > > p_Y(y) = p_X( g(y) ) * |f'( g(y) )|^(-1) > > where y = f(x) = f( g(y) ) and x = g(y) = g( f(x) ) > > so g() is the inverse function of f(). p_Y(y) and p_X(x) are the > p.d.f's of the output and input random numbers, Y and X, > respectively. the spectrum of the output is left unspecified, but i > think a pretty good case can be made that if the input to the non- > linear function (X) is white (that is, the correlation between samples > is zero), the same can be said for the output of the non-linear > function Y. > > now, this is not a proof and i cannot guarantee it will always work, > but i would suggest to first generate a white and gaussian RN (add > together a dozen independent uniform RNs, that's good enough, or run a > uniform RN through a non-linearity to get something approximating > gaussian). then filter that gaussian through the necessary filter to > get you a guassian signal, but with the spectrum (or autocorrelation) > that you seek. then take that colored, gaussian RN and run that > through a non-linearity to get the p.d.f. that you seek. > > it will get you close. perhaps after creating this generator, you can > generate a few billion samples overnight and run statistical analysis > on it to see if you got the spectrum you really want (in case the non- > linearity changed it). the p.d.f. should be exactly correct. > > r b-j
hi, r b-j: Thanks for you response. Your explanation is very detailed and I've got it. Besides the p.d.f and spectrum, what requirement that I expect is about auto-correlation. What I am confused is, whether the need on auto-correlation and spectrum power are identical? seems not in mind. I want a serial of random samples, each one is dependent on its neighbors, but two samples far away is independent, rather than two neighbor samples have zero dependency. So it seems not "random". Then the auto-correlation seems to have a wide pead, not only a pulse at zero. If normalize the auto-correlation by dividing the samples' power ( mean square of samples), say it Cor_Nor( n ), then Cor_Nor( 0 ) = 1, which is universal. Moreover, I want some other orders in Cor_Nor(n), say Cor_Nor(-3), Cor_Nor(-2), Cor_Nor(-1), Cor_Nor(1), Cor_Nor(2), Cor_Nor(3) all have much value, say respectively 0.6, 0.7, 0.8, 0.8, 0.7, 0.6, then to form a wide peak with Cor_Nor(0) in the auto-correlation function. This dependency is more important than two other aspects, p.d.f and spectrum power. I wonder whether it is possible to design it. BR. wayne
robert bristow-johnson wrote:
> On Dec 5, 8:44 pm, Jerry Avins <j...@ieee.org> wrote: >> robert bristow-johnson wrote: >>> On Dec 5, 5:36 pm, Jerry Avins <j...@ieee.org> wrote: >>>> John wrote: >>>> ... >>>>> Does the nonlinear function need to be symmetric too? Otherwise >>>>> couldn't it potentially create a DC bias in the output? >>>> It needs to be symmetric if you don't want DC. It needs to be asymmetric >>>> if you do want DC. >>> well, that all depends on what the input p.d.f. is. if the input >>> p.d.f. is symmetric about 0, then its mean (DC) is 0 and, if you want >>> no DC in the output, the mean, determined from the p.d.f. needs to be >>> zero, but it does not have to be symmetric. >>> even if the nonlinear function had (odd) symmetry, if the p.d.f. going >>> in had a non-zero mean (a DC component), the p.d.f. coming out would >>> not have to have the same non-zero mean. wouldn't that be a DC bias? >>> so, as far as i can tell, symmetry of the non-linear mapping is >>> neither necessary nor sufficient to preclude a DC bias (or a shift in >>> the mean of the p.d.f.). >> I thought that the PDF you prescribed as input was uniform. >> > > but it wouldn't have to be zero mean. > > most random number generators generate a non-negative, uniformly > distributed pseudo-random integer that is from 0 to 2^(N-1) - 1 where > N is the number of bits in the word (and each RN is independent, so > it's white up to Nyquist). at least that's what rand() does (gcc > stdlib). but, of course, it's easy to unbias that by subtracting > 2^(N-2), but you *could* just run the raw (biased) RN into the non- > linear mapping, and if it's defined right, get a zero-mean, virtually > Gaussian RN coming out. > > but, my main point is that symmetry (about 0) of a p.d.f. *will* > guarantee that it is zero mean, but you can create a zero mean out of > any non-symmetrical p.d.f. by first calculating the mean and then > subtracting that mean from the RN. the result is a p.d.f. that has > zero mean, but is not symmetrical. > > also, if the RN going into a non-linear function with odd symmetry was > a zero-mean RN, but with an assymetrical p.d.f., it's not necessarily > true that what comes out will be zero mean. > > but, this is true: RN with symmetrical p.d.f. about 0 (which is > necessarily zero mean) goes into a function that has odd symmetry --> > the result will be another RN with a symmetrical p.d.f. about 0 (which > means it also is zero mean). that is true.
Thanks. Always more than meets the eye. It's almost obvious once you spell it out. jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;