RTXI 1.3
plugins/include/DSP/ma_est.cpp
Go to the documentation of this file.
00001 //
00002 //  File = ma_est.cpp
00003 //
00004 
00005 #include <stdlib.h>
00006 #include <fstream>
00007 #include "ma_est.h"
00008 #include "gausrand.h"
00009 #include "yulewalk.h"
00010 #include "sig_type.h"
00011 
00012 #ifdef _DEBUG
00013   extern std::ofstream DebugFile;
00014 #endif
00015 
00016 //========================================================
00017 //  MaEstimate - subclass of MaProcess for the case where
00018 //  the MA coefficients must be estimated from observed data
00019 
00020 template < class T >
00021 MaEstimate<T>::MaEstimate( int est_ma_order,
00022                            int durbin_ar_order,
00023                            T* sig_seq,
00024                            int seq_len)
00025                :MaProcess<T>()
00026 {
00027   int i, err_stat;
00028   T *a_coeffs;
00029   YuleWalker<T>* yw_ptr;
00030 
00031   Ma_Order = est_ma_order;
00032   Noise_Seed = 31415927; // arbitrary default
00033 
00034   Old_Input = new T[est_ma_order+1];
00035   for( i=0; i<=est_ma_order; i++) 
00036                 Old_Input[i] = 0.0;
00037 
00038   //---------------------------------------------------------
00039   //  Fit high-order AR model to the data
00040 
00041   a_coeffs = new T[durbin_ar_order+1];
00042   
00043   yw_ptr = new YuleWalker<T>( sig_seq, seq_len, 
00044                               durbin_ar_order,
00045                               a_coeffs, &Drv_Noise_Var, 
00046                               &err_stat);
00047 
00048   delete yw_ptr;
00049 
00050   //----------------------------------------------------------
00051   //  Use high-order AR coefficients in place of data
00052   //  to fit desired order MA model
00053 
00054   double dummy_var;
00055   B_Coeffs = new T[est_ma_order+1];
00056   
00057   yw_ptr = new YuleWalker<T>( a_coeffs, 
00058                               durbin_ar_order+1,
00059                               est_ma_order,
00060                               B_Coeffs,
00061                               &dummy_var,
00062                               &err_stat);
00063 
00064   delete yw_ptr;
00065   delete[] a_coeffs;
00066   return;
00067 }
00068 
00069 //------------------------------------
00070 //  Explicit instantiations
00071 template MaEstimate < type_of_sig_vals_T >;
00072 //template MaEstimate<complex>;
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines