0
$\begingroup$

I have a discrete series of values and I have applied a Discrete Cosine Transform to it, obtaining values like:

2.669825
0.23372388
0.034602005
0.14609262
-0.05658116
0.028039198
-0.019894773
-0.12209733
0.022227166
0.0051003816
-0.042596065
-0.04589792
0.01035949
-0.019523097
0.077776365
0.0030713473
-0.078441024
-0.00070093106
0.01997262
0.06481835
-0.004874494
0.023854036
0.029294237
0.011619994
-0.0012118752
0.010400612
0.023407647
-0.05563956
0.038198948
-0.01233741
0.009424317
0.039608873
0.05801
0.028565174
-0.012889689
0.021731874
-0.026493106
-0.048108768
0.0045189788
-0.032068893
-0.017894993
-0.025662154
0.010751593
-0.07121442
0.06277961
0.0022988198
-0.018414639
-0.021932043
-0.020916257
-0.01747331
0.006716689
0.023302665
0.0068657864
-0.019596279
-0.043121584
0.04483221
-0.00012186449
-0.012160094
0.011104634
-0.015813472
0.023498433
0.02872037
0.014691476
0.015423553
-0.032783255
0.028947365
0.03251956
-0.016012289
-0.018248938
0.026564144
-0.034706548
0.012790314
0.002194486
0.04613065
-0.05747463
0.010088965
0.017059956
-0.04142371
-0.040067486
0.0029621175
0.07121314
-0.0064264582
-0.0064690933
-0.040944442
-0.0025974065
0.0075896196
-0.006084161
-0.027271878
0.056449506
-0.01756429
0.020225035
0.05740238
-0.07323427
0.091452986
-0.06606907
-0.00599443
0.03895919
0.0029399507
0.0050259903
-0.017262679
-0.052305933
0.0132182
-0.14926372
0.12026562
0.06996072
0.050748315
0.020096999
-0.017148953
0.006768549
-0.07308701
0.045742266
-0.055744015
0.034470245
-0.06591675
0.012785097
-0.045998022
0.028786233
-0.0006729504
0.026651034
0.016280383
-0.016419016
-0.0235405
-0.011106867
0.0060093636
-0.026253335
-0.020966358
0.049879722
-0.019093664
0.055243053
0.008216016
0.039922368
-0.05096092
0.010148679
-0.011200655
0.044212196
-0.012730424
0.027963173
-0.0050371652
0.0006729523
-0.02703674
-0.040479846
0.0032800399
0.019346198
0.03412081
-0.0062747486
-0.018566221
-0.011666842
0.02345107
-0.07089561
0.023972765
-0.0076217707
0.00794466
-0.008454496
-0.051500462
0.007845432
-0.046568125
-0.018137766
0.026703745
0.035737798
-0.061839998
-0.00884305
0.009104564
0.052314416
0.028979728
-0.017012393
-0.019422699
-0.049617197
0.03505949
0.005899897
0.031378012
0.02203784
0.05013973
-0.014152746
0.029270608
0.049914937
0.01226829
-0.038096413
0.012367716
-0.04856258
0.008609608
-0.014275378
-0.00032820972
0.003259441
0.04173329
0.0026449636
0.020232702
-0.058400147
0.006697319
-0.083465755
0.023861019
-0.019418886
-0.034204446
0.057170536
-0.03352673
-0.020436082
-0.024796713
-0.054371275
0.055950172
-0.01681035
0.018895034
0.042727623
0.040553555
-0.049501
0.003925497
-0.034148764
-0.00027683005
-0.054910377
0.03833572
0.053599093
0.02369698
-0.0021882567
0.04318303
0.0055106683
-0.026357781
-0.0022721058
-0.036762282
0.06495822
0.030521873
0.003908515
-0.052683424
-0.00785333
-0.0245375
-0.006546188
0.03067175
0.046067707
0.0047659995
-0.03191337
0.010508363
-0.0308632
-0.016877536
-0.05901345
0.0061260397
0.008024132
0.052667245
-0.026830386
0.021430418
-0.044398945
-0.02600174
-0.032572
0.06329122
0.032917332
0.0284806
-0.074899085
-0.025770163
-0.015752867
0.0030335134
0.04120659
0.0026583495
-0.005403653
0.009906204
0.029109228
0.015893774
0.0023716427
-0.02794688
-0.033177476
-0.08380169

How do I find the frequency of a particular bin? Suppose the first one, equal to 2.669825 a huge peak compared to the others.

Also, if I want to filter it by frequency, how do I do that? Suppose I want to get rid of all frequencies above 10 Hz...

Ah, and what is the meaning of the negative terms?

So, I have 3 questions for you:

  1. How do I find the frequency of a particular bin in a DCT?
  2. How do I filter frequencies using the DCT results?
  3. What is the meaning of the negative terms?

I know the answer to all these items may be extensive, bear with me, if not possible, just give me directions to follow.

$\endgroup$
1
$\begingroup$

DCTs (they exist under different flavors) map data along some cosine-related frequency axis, from $0$ to... the maximum frequency of your data, which we don't know, since we don't have its sampling frequency. So the realtive frequency index is implicit, between $0$ and $255/256$ in relative frequency. $2.669825 $, mostly probably, is the DC component, here the average of your signal, divided by $\sqrt{N}$, where $N$ is your number of samples ($256$). If I try to reconstruct your data with a type-II DCT, here is what I get:

Signal and DCT

The so-called "Frequency index" should be taken with caution, as it really depends on the DCT flavor, as commented be RBJ.

I'm not sure the signal is exactly yours, as I did a guess on the DCT type. To filter above $10$ Hz, you can see to zero the amplitude of all frequency indices above some ratio related to your sampling frequency. DCTs are discrete transforms, acting on signals with "unit" sampling period. So without data sampling information, you cannot get Hertz from the DCT spectrum alone, unless you know spectral characteristics on your signal that can be detected in the spectrum.

Negative values simply mean that the cosine contribution at that frequency is negated.

But if you want to filter data, using a discrete Fourier transform is probably more appropriate.

$\endgroup$
  • $\begingroup$ is there any formula that relates each bin of the DCT with a frequency in Hz? $\endgroup$ – SpaceDog Feb 13 at 22:28
  • 1
    $\begingroup$ it really depends on which "flavor" of DCT. $\endgroup$ – robert bristow-johnson Feb 14 at 1:01
  • $\begingroup$ DCT type II..... $\endgroup$ – SpaceDog Feb 14 at 17:13
  • $\begingroup$ DCT is dimensionless. Without any hint from the physical world, it's very hard to get Hz back $\endgroup$ – Laurent Duval Feb 22 at 20:00
  • $\begingroup$ thanks!!!!!!!!! $\endgroup$ – SpaceDog Apr 4 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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