# Review of spectral estimators

We have two classes of spectral estimators in LTPDA: one class based on the standard WOSA (Welch's Overlapped Segmented Average) and a modified version of WOSA which estimates the spectral quantities at frequencies spaced logarithmically.

## Estimating Power Spectral Densities

To estimate the Power Spectral Density of a time-series, you can use the method ao/psd or the logarithmically spaced frequencies version, ao/lpsd. For example:

```      % Generate a time-series of random numbers
a   = ao.randn(100, 10);

% Compute a PSD with the default configuration.
axx = psd(a);

% Plot the result
iplot(axx)```
The psd method has various configuration parameters to adjust its behaviour. These are described in the method's documentation. If you do:
`      help ao/psd`
and then click on the 'Parameters Description' link, you should see a documentation window with a full table describing the parameters for psd. To get a brief list of the plist keys available, you can simply do:
```      >> keys('ao', 'psd')
------------------------------------------------
Default
------------------------------------------------
NFFT, WIN, PSLL, OLAP, ORDER, NAVS, TIMES, SCALE```

So, to compute the Amplitude Spectral Density of a time-series with a certain number of averages, you do:
```      % Generate a time-series of random numbers
a   = ao.randn(100, 10);

% Create a plist to configure ao/psd
psdPlist = plist('navs', 10, 'scale', 'asd');

% Compute the PSD of the time-series with the given configuration plist
axx = psd(a, psdPlist);

% Plot the result
iplot(axx)```

The logarithmic-spaced version of PSD (ao/lpsd) shares some of the configuration keys with ao/psd. As such, you can, more often than not, simply interchange them:
```      % Generate a time-series of random numbers
a   = ao.randn(100, 10);

% Create a plist to configure ao/psd
psdPlist = plist('navs', 10, 'scale', 'asd');

% Compute the logarithmically spaced PSD of the time-series with the given configuration plist
axx = lpsd(a, psdPlist);

% Plot the result
iplot(axx)```
(You will notice that lpsd doesn't respond to the key 'NAVS' since it computes the number of averages per frequency bin itself. You should see that LTPDA warns you that the key 'NAVS' is ignored.)

## Estimating transfer functions, cross-spectral densities and coherence

Transfer functions can be estimated from input and output data using the ao/tfe method (or the corresponding log-spaced method, ao/ltfe). Here's an example:

```      % Sample frequency of our data
fs = 10;

% Generate a time-series of random numbers
input   = ao.randn(100, fs);

% Create a digital filter
myFilter = miir(plist('type', 'bandpass', 'fc', [0.5 1], 'fs', fs, 'order', 3));

% Filter the noise data
output = filter(input, myFilter);

% Estimate the transfer function from input to output
T = tfe(input, output);

% Plot the result
iplot(T)```
Cross-spectral densities can be estimated using ao/cpsd (or ao/lcpsd) and coherence can be estimated using ao/cohere (or ao/lcohere).