Produce PSD from a FFT output I am using an FFT function in PHP language (https://gist.github.com/mbijon/1332348) which works very well, but cant produce PSD from its output:
$fft = Fourier($data,1);
// $fft[0] is real portion of 1
// $fft[1] is imaginary portion of 1
// $fft[2] is real portion of 2
// $fft[3] is imaginary portion of 2
// ...
// $fft[n-1] is real portion of n
// $fft[n] is imaginary portion of n

PSD formula In Matlab:
PSD = Y.*conj(Y)/N

I cant understand this formula in math notation form...
How can I adapt this formula to work with that output?
Indeed, PHP is not a weapon of choice to do signal processing. But if you absolutely need to &quot;adapt&quot; the matlab formula, here is an one-liner to &quot;conjugate&quot; the data, based on commented lines from the code of your question (// $fft[0] is real portion of 1, etc.):
// PHP's $conjdata[·] stands for matlab's conj[Y] 
for ($i = 0, $cnt = count($data), $ri = 1; $i &lt; $cnt; $i++, $ri = -$ri) $conjdata[$i] = $data[$i]*$ri;

Also, the PSD formula is somewhat trickier than just Y*conj(Y)/N. See, for example, https://stackoverflow.com/questions/3949324/calculate-autocorrelation-using-fft-in-matlab, the second answer.