## Bin frequency amplitude estimation for convolution

Started by 4 years ago●28 replies●latest reply 4 years ago●222 viewsHello everyone,

I am new here and I hope I could learn more from experts.

My question is related to convolution when the impulse vector does not meet the whole bin frequency and you have restriction to change Fs (sample frequency ) or N ( number of samples).

Assume that I have n samples (bins). Assume also I have fix Fs sample frequency with constant N samples that I could not change. Now, if an even as an impulse happens between two bin frequency how could I make the impulse vector?

As an example :

if impulses happens int he bin frequencies :

impulses vector:[1 0 0 0 0 0 0 0]

original vector:[2 4 3 4 5 6 7 8 9]

now assume that an impulse happens at position 3.34 bin frequency. Is there any way without increasing sample frequency or sample number I construct the some weighted impulse vectors that be corresponded to the impulse that happens in 3.34 bin? I know that when an event happens between two frequencies we have smearing ( leakage effect on other bins) so could I reconstruct the impulse vector with some weighting of the whole bin numbers ? in this case how could I find the coefficients of each bin

For example maybe the impulse vector becomes like :

Impulse vector :[0 .2 .43 .5 .41 .1 0 0 0]

Thanks

You got the right idea. The simplest way is to split it between 2 bins. With amplitude one, you put .64 in bin 3 and .36 in bin 4. The same happens in reverse - if you have a pure tone that would reside at location 3.34 it will split between the bins.

It's actually messier than that - you should use a sinc(x) function to spread things out. But for testing and playing around, just split the amplitude between 2 closest bins.

Thank you Drmike!

I am actually looking for the exact solution how to split it. Is it possible to let me know how you came with .64 and .36 values for bins three and four?

Also why you put 1 for bin 2 and 3? because the actual frequency is not 2 or 3 the energy of the frequency should be spread to number of adjacent bins.

Basically the frequency of such signal ( which is not lies on bins) and the frequency resolution determines how many bins receive the energy from the signal. Am I understood it correctly? the next challenge is how to calculate the exact value of each amplitude that you mentioned about Sinc function. Is there any website or article that exaplain such situation with example that I could understand it fully?

Thank you so much

A good topic to search on that will help understand this is "window functions" for DFT or FFT. There are many good papers and tutorials. There is always a window, even if it is rectangular, and the sinx/x (sinc()) that DrMike mentioned goes with a rectangular window.

Start here:

https://en.wikipedia.org/wiki/Window_function

then follow Startibartfast's comment with a google search.

Thank you dr!

Still it is not easy to follow it. I am looking to find a solution from an example that I could understand it.

For example if I have Fs=10 Hz and N=10 ;

in this case frequency resolution is 1.

so assume that I want to make a vector in time domain and an event as an unit impulse happens in 3.43 index in time.

Then how would be the true result of such 10 vector elements in time domain ?

Clearly none of the elements should be one and some connected bins needs to get some weight.

Thanks

OK - so the trivial way I suggested the first time is to use the index you know the impulse happens at as the weight distribution. Assume the amplitude of the impulse is 1.

You say it happens at 3.43. So we draw a unit impulse 1 bin wide and 1 high centered at 3.43. That means bin 3 gets .57 of the width and bin 4 gets .43 of the width. So in your plot, you have 2 bins with data and the sum of their heights is the same as the original impulse.

If you draw this out on a piece of paper it should make sense. Life is more complicated that this, but it is a good conceptual starting point.

Thank you Dr!

I think I got your idea but when I center the SINC function in 3.42Hz center or basically the following function Sin(pi*(x-3.42))/(pi*(x-3.42)) I get .7224 for third bin (x=3) and .545 for fourth bin x=4.

Could you please let me know how did you manage to get .42 and .57?

In addition to it should not I consider the value of the other bins in my set ? for example for that function I get the value of Sinc at second bin ( x=2) is -0.217

Thanks

That's where the windowing comes in. If you have a theoretical impulse, it has zero width and infinite height. But we can't do anything with that, so for modeling we use an impulse of finite height. In time domain, the bin width is the sampling time. In the frequency domain, the bin width is the frequency resolution. The relationship is $ T = \delta t N $ and $ \delta f = frac{2}{T} $ If you don't have an impulse, but you have wider pulse, then yes, the energy would be spread out over more bins.

Thank you Dr for great explanation. I think in the time that I was editing my post you replied me.

You mentioned that the sample time is bin size. I watch a Youtube video at https://www.youtube.com/watch?v=fEY92cwxj9A if you scroll at 1:20 it shows the picture of sampling parts.So you mean that symbol Taw in the video is actually 1/Fs ( 1/sample frequency).

Regarding to your answer I got the whole picture but when I centered the SINC function at 3.42 Hz or basically the following function Sin(pi*(x-3.42))/(pi*(x-3.42)) I get .7224 for third bin (x=3) and .545 for fourth bin x=4.

I uploaded the picture of such Sinc function so please click on the

Could you please let me know how did you manage to get .42 and .57?

In addition to it I should not consider the value of the other bins in my set ? for example for that function I get the value of Sinc at second bin ( x=2) is -0.217

As far as I understood those parts are related to the leakage So I should not consider them right?

Thanks

The idea is to use a 1x1 square. If it sits on 2 bins b and b+1 then fraction f is put into bin b+1 and fraction 1-f is put into bin b. This is wrong on many levels, but easy to do.

Putting the negative value into the bin is fine. You should consider them since this is a square window function. If you use a smoother window you'll get less spread. Play with it and see what happens!

Thanks Dr!

What I plotted in the picture in the previous post was wrong? (You needed to click on the picture text or here at https://pasteboard.co/IA0GprW.png)

I still do not understand why you got .57 for bin three and .43 on bin 4

When I fit the sinc as I wrote in the previous post that I showed in the picture I get .7224 for third bin (x=3) and .545 for fourth bin x=4

Thanks

I think your time is better spent figuring out how a window works and how time domain to frequency domain transitions work with fixed parameters. Take a sine wave which exactly fits N steps and do your DFT. Then do a triangle wave with the same N steps. Then do a square wave. How does the frequency domain change? Now add a window function and do it all again. How does the result change?

Then go back to the impulse. You need to get a feel for the time domain and frequency domain information content. Once you see how they relate, the impulse response will be "obvious."

Hello Dr

Could you please answer the question that I posted? when you move to other topics it makes me more distracted.

I know that Square has odd frequency bins and triangle has even frequency bins and just one impulse excite all frequencies.

Thanks

I did - you didn't understand. I'm sorry I can't explain it better because it seems so trivial (and it's wrong too, so really there's no point).

If you set a unit square on a ruler so it's mid point is at (integer x + fraction f), then bin x holds fraction 1-f of the square and bin x+1 holds fraction f of the square.

Thanks Dr.

Yes I did not understood exactly your point and if someone understood it please let me know. But what is the right way then.

So far what I understand is that the Sinc could be used to interpolate the sample of the places that I do not have.

But my point is that without changing the sample numbers and Fs, is there anyway to distribute the energy of the unit impulse ( that I did not sample it ) to the current N samples somehow? Because I want have N vector time domain and I not for example an event happens at 3.42 time bin.

Thanks

There is ambiguity as what is your issue:

Let me ask these questions first:

1) what is your platform: dsp, or pc matlab or fpga...?

2) what is your given input

3) what output you want

remember if you have 10 samples you cannot index with anything other than 1:10 in matlab or 0 to 9 in hardware...

Hello Kaz!

Please check the last comment between me and Drmike

Thanks

I still can't see the answers to my questions.

If your time domain input is an impulse then its frequency response is same on all bins. You don't need to do anything else about points between bins.

If your input is a band of frequencies and you actually want to find a bin that is not computed by regular FFT then say so.

Interpolating across bins is not the best way if the spectrum is changing fast across bins.

Hello Kaz,

1) what is your platform: dsp, or pc matlab or fpga...? octave(matlab)

2) what is your given input ? N=10 Fs=10 x=[0 0 0 0 0 0 0 0 0 0]

3) what output you want ? I was thinking assume at time 0.17 a unit impulse happens. Although I miss that event in the sampling ( because the sampling happens at .1 seconds) but I want to know is there any way by not increasing N or changing Fs I could change the x vector in a way that it represents the same effect when a unit impulse happened at 0.17 seconds on the current x vector ( without changing the length of the vector x)? we all know in frequency domain you could have any fraction frequencies but it just leaks to all K samples.

So all I am talking is in time domain.

Well your question is not right if you are already in digital domain. It might make some sense if you are imagining an analogue impulse event that the ADC missed then the scanario changes to ADC sampling speed or its clock phase for such infinitely short pulse. I don't see this can be modelled in digital domain but yes there is possibilty of fractional interpolation of a signal that has enough information.

So it will be better if you can explain your task. Is it industrial task or University task that is poorly presented to you.

Hello Kaz!

Thanks for the answer. No related to any particular tasks but For example maybe there is a hardware that has fix N sample memory and fix Fs. I know the exact time where an impulse could happen located in a time some where that I know between samples. So I want to know if I have a fix x array size with fix sample frequency is there anyway that I could represent that event (that I know it is an unit impulse) that I could not capture with the current n index bins in digital time domain with some weighting of the current digital time domain bins?

I am a bit confused why in frequency domain we could do this. For example maybe my frequency resolution is .5 but I could capture a frequency .2 Hz on the current frequency bins but obviously it will be leaked but still you could do it. So I was thinking if the same could happens in digital time domain

Thanks

so basically you want to understand it for your own knowledge.

Your comparison between time domain and frequency domain is interesting.

in digital time domain an impulse is one sample anyway and you can't go in between. if on the other hand you have a varying signal in time domain sampled at ADC you can indeed go in between samples in terms of signal shape using fractional resampling. In fact this method is used in symbol timing recovery as a digital alternative to sample peaks at ADC. You sample it at random but can reshape the signal to get better peaks.

Frequency domain is computed by contribution from all input samples.

even if input is an impulse the other samples are zero and contribute and that means frequencies all over.

A further way of thinking is that with frequency domain you convert from a given time domain series. you can do the reverse from a given frequency domain to time domain using ifft. so if you choose first to shift your frequency bins by some fraction, do ifft and see what you get.

Hello Kaz,

Thank for the info and your complement!

So from what I understand there is no way. The only way is that I increase the N if Fx is fixed in order to put that impulse inside X vector.

Thanks again

even if you insert the impulse anywhere it is still just an impulse with advance or delay and the fft will always show flat amplitude but different phase.

With signal processing you better take the perspective of ADC => digital domain rather than an abstract digital vector.

If your vector is a varying signal as opposed to impulse then you can do fractional delay/advance using same size vector and same Fs.

Hello Kaz!

mm I am a bit confused by your last paragraph of your comment.

How could I use delay in digital domain by fraction if I want to keep the length and Fs fixed and do continuously sampling?

Let's back to the same problem : Fs=10 N=10 X vector content could be varying but I want to have fix length of X and fix Fs

Assume the unit impulse happens at 2.32 then how delay could solve this situation? as far as I understand again digital delay should be based on the integer index shift and not any fraction number right?

Thanks

Fractional delay is a bit advanced topic. The sample values are changed (per each sample) such that the "signal" shape looks as if it was delayed or advanced relatively i.e. it emulates the ADC changing sampling phase of analogue signal and assumes signal trend hasn't changed unexpectedly in between samples. The integer delay is a subset when "fractional" delay = 1.0 and simply means shift of stream. Your impulse case can only be integer delay if you keep the shape as impulse.

Hello Kaz!

Thanks for the info!

It is interesting about fractional delay. I am trying to understand it. But as I see and you mentioned the shape of the signal during the fractional delay should not change rapidly. In my case it changes right? Because suddenly I have an impulse between two time index so still I could not use it?

Even if I assume the event happens in stream I could not use this method as far as I understood in my case. For example in all integer*2.41 time sample interval this event happens. I could use this method if the sudden change happens in the current integer time scale and I want to see the transition of it right?

I think DSP is really interesting topic if you understand it right. Do you have a good book that you could recommend me to read it? I had DSP course in school long time ago but the teacher was terrible and I gave up to learn it properly that time. However, I am trying to learn it with fantastic sources that are available in internet nowadays and made all the scary math behind the scenes very tangible and pleasant for everyone.

Thanks!