Menu

how to get the autocorrelation of a piece of data

DeanTT
2014-09-26
2014-09-29
  • DeanTT

    DeanTT - 2014-09-26

    does Sphinx have some functions, that I can use to get the autocorrelation of a frame of data

    Thanks a lot

     
    • Nickolay V. Shmyrev

      To get autocorrelation of two arrays you don't need any function or sphinx API. You can just write a simple loop according to formula. It is 5 lines of code.

       
      • DeanTT

        DeanTT - 2014-09-27

        Thanks Nick, another problem with the IFFT which I don't understand how to use:

               DiscreteFourierTransform  lpcDft = new DiscreteFourierTransform(512, false);
               lpcDft.setPredecessor(hammingWindower);
               lpcDft.initialize();
        
               DiscreteFourierTransform  idft = new DiscreteFourierTransform(512, true);
               idft.setPredecessor(lpcDft  );
               idft.initialize();
        

        For example: data -> DFT->IDFT -> data2 the data and data2 is different, the points after DFT is 257 which cut in half of the setting fft point, I understand this.

        But why the idft does not return back to 512 points output, instead it is still a 257 points output.

        Generally how should I use the IDFT?

        Thanks

         
        • Nickolay V. Shmyrev

          But why the idft does not return back to 512 points output, instead it is still a 257 points output.

          Signal is decomposed on magnitude and phase. Phase values are dropped in speech recognition. If you want to resynthesize the sound back you need to somehow submit a phrase. Usually people use random phrase or phase from original signal. There are more advanced methods of phrase restoration.

          Generally how should I use the IDFT?

          Depends on your goals.

           
          • DeanTT

            DeanTT - 2014-09-29

            Hi, Nick

            what am I trying to do is use fft and ifft to compute the autocorr(used for the linear prediction) of the data, because the direct convolution in the time domain is much slower than doing it via FFT.

            The way recommanded is this:

            X = fft(x)
            XX = abs(X).^2
            x_autocorr = ifft(XX)

            and I know the fft in sphinx returns the power spectrum and half of the symmetry. Say I have a frame of data with 512 points, its autocorr should be 2*512-1=1023 points.

            I set:
            DiscreteFourierTransform dft = new DiscreteFourierTransform(512, false);
            I use the dft on the frame, it returns a 257 points fft result;

            then I can't figure out how to use the ifft in sphinx to get the correct 1023 points result(autocorr)

            any advice, thanks a lot

             
            • Nickolay V. Shmyrev

              If you want to compute autocorrelation you need to take fft of dimension twice the number of points in vector:

              http://stackoverflow.com/questions/3949324/calculate-autocorrelation-using-fft-in-matlab

              So if you have 512 points you need to take FFT of size 1024 and that would give you 1024 points after IFFT.

               

Log in to post a comment.

Auth0 Logo