Investment Studio > Expressions > Functions > DSP > MEMF

Short form: float array[1][2] memf(float array mem_coefficients, boolean power, float normalized_frequency)

Returns a two-column row vector containing (by column):

  1. The power (if power = TRUE) or amplitude (if power = FALSE) of the MEM-estimated spectrum given by mem_coefficients (see mem), evaluated at normalized_frequency; and
  2. the normalized_frequency.
Long form: float array[steps][2] memf(float array mem_coefficients, boolean power, float from_normalized_frequency, float normalized_frequency_step, integer steps)

Returns a two-column array. One row per frequency step. Each row contains (by column):

  1. The power (if power = TRUE) or amplitude (if power = FALSE) of the MEM-estimated spectrum given by mem_coefficients (see mem), evaluated at the normalized frequency stated in the second column; and
  2. The normalized frequency = from_normalized_frequency + (row number - 1) * normalized_frequency_step.

All elements in mem_coefficients are converted to floats (with exclusion if conversion fails) and interpreted as a single, one-dimensional sequence. If the data array is two-dimensional, it's read in the usual order (i.e. row by row: left to right, top to bottom).

Normalized frequencies are frequencies expressed as fractions of the sampling rate. The sampling rate is the inverse of the sampling period. The highest frequency component that can be reconstructed from a sequence of evenly sampled values is half the sampling rate (Nyqvist's theorem), so normalized frequencies higher than 0.5 (the Nyqvist frequency) are not meaningful.

See mem for details on MEM (Maximum Entropy Method) estimation of power spectra.

Example

Given the 1024-point sine wave with normalized frequency 0.06 and amplitude 1,

_data = mop("sin()", makevector(1024, 0, 12 * PI / 100))

the expression

=memf(mem(array(_data), 10), TRUE, 0.059, 0.001, 3)

returns {{0.000601123782154787, 0.059}, {2.91527390385097, 0.06}, {4.38363611718493E-7, 0.061}}.

This tells us the values of the 10-pole MEM estimate of the wave's power spectrum (since power = TRUE) at the normalized frequencies 0.059 (first row), 0.06 (second row) and 0.061 (third row).

See the mem example for a graph comparing the 10-pole MEM and the DFT spectral estimate of _data.

If all we want is the value in one point, we can use the short form of memf. For instance,

=memf(mem(array(_data), 10), FALSE, 0.06)

returns {1.70741853441453, 0.06} telling us the 10-pole MEM estimate of the wave's amplitude spectrum (since power = FALSE) at the normalized frequency 0.06.

See also fftc, fftp, mem, memdom, memp.