I have a physical system that I'd like to obtain the frequency response for. I can only provide binary sequences as inputs to the system. Normally, I'd use a MLS (maximal length sequence) and calculate the empirical transfer function via fft(output)/fft(input) where the input for a MLS is conveniently white, or calculate the cross correlation of the output with the MLS (conveniently has an impulsive auto correlation) to get the impulse response and then the frequency response from that.

However, I have a specific problem where my input sequence must be unbalanced by a specified amount: the number of ones differs from the number of zeros and the mean value (or duty cycle) of the input sequence should be some specified value other than 0.5.

So the question is: are there existing binary sequences with the following properties:

  • Specified mean value, and
  • White (or nearly white) frequency content, or
  • Impulsive (or nearly impulsive) auto-correlation
  • $\begingroup$ If the signal frequency content is white or nearly white, then the mean is necessarily zero or nearly zero. The MLS that you are using has a periodic autocorrelation that is nearly impulse-like, and spectrum that is nearly white, and mean that is nearly zero. Be aware that many physical systems are nonlinear and exhibit linear behavior only in the near-vicinity of their "operating points", and this linear small-signal behavior is what one is often trying to determine. $\endgroup$ Commented May 17 at 18:48
  • $\begingroup$ Dilip Sarwate, your comment that if the signal has a white spectrum then the mean is zero isn't true (or I've misunderstood your meaning). The most extreme case is [0 1 1 1 1 1 1 ...] which has a perfectly white spectrum but the mean value approaches 1. $\endgroup$
    – tkw954
    Commented May 17 at 20:13

2 Answers 2


Well, you can always produce a random sequence that has (for example) 70% ones and 30% zeros.

The spectrum of this sequence will generally be white-ish: meaning it's mostly flat over the entire frequency range line but with a fair amount of local variation between neighboring frequencies. If you smooth it, it will approach a true white spectrum.

The mean will obviously be 0.7 (in this example). You can change the mean by adding a bias simply but than you don't have ones and zeros anymore (which may be fine for your application).

The autocorrelation of this sequence will indeed be impulse like. It will have a big honking peak at $n=0$ but the rest will not be zero but a small amount of white noise which depends mostly on the length of the sequence

This noise will limit the dynamic range of the impulse response. If that's acceptable, than you can use indeed cross correlation to calculate the impulse response of the system.

You can also use spectral division to calculate the transfer function exactly. The problem here is that there will be individual frequencies where the signal spectrum is quite low so you may have SNR or or noise amplification problems at these specific frequencies. There are multiple methods to work around that but these are all quite complicated and there is no "one size fits all" and would have to be optimized to your specific requirements and the properties of your system.


It is impossible to simultaneously have a non-zero mean and an auto-correlation that is an impulse function because the non-zero mean component correlates in time, so the minimum circular auto-correlation will be $np^2$, where $n$ is the sequence length and $p$ is the mean sequence value, whilst the peak will be $np$, so it will only approach an impulse auto-correlation as the mean approaches zero.

In general, generating a random variable with a Bernoulli distribution sounds conceptually like what you are interested in. This might be realised in Matlab using the binornd function, for example an $n$ element sequence with mean $p$:

r = binornd(1,p*ones(n,1));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.