RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ma_est.cpp
Go to the documentation of this file.
1 //
2 // File = ma_est.cpp
3 //
4 
5 #include <fstream>
6 #include <stdlib.h>
7 #include <iostream>
8 
9 #include "ma_est.h"
10 #include "gausrand.h"
11 #include "sig_type.h"
12 #include "yulewalk.h"
13 
14 #ifdef _DEBUG
15 extern std::ofstream DebugFile;
16 #endif
17 
18 using namespace std;
19 
20 //========================================================
21 // MaEstimate - subclass of MaProcess for the case where
22 // the MA coefficients must be estimated from observed data
23 
24 template <class T>
25 MaEstimate<T>::MaEstimate(int est_ma_order, int durbin_ar_order, T* sig_seq,
26  int seq_len)
27  : MaProcess<T>()
28 {
29  int i, err_stat;
30  T* a_coeffs;
31  YuleWalker<T>* yw_ptr;
32 
33  this->Ma_Order = est_ma_order;
34  this->Noise_Seed = 31415927; // arbitrary default
35 
36  this->Old_Input = new T[est_ma_order + 1];
37  for (i = 0; i <= est_ma_order; i++)
38  this->Old_Input[i] = 0.0;
39 
40  //---------------------------------------------------------
41  // Fit high-order AR model to the data
42 
43  a_coeffs = new T[durbin_ar_order + 1];
44 
45  yw_ptr = new YuleWalker<T>(sig_seq, seq_len, durbin_ar_order, a_coeffs,
46  &(this->Drv_Noise_Var), &err_stat);
47 
48  delete yw_ptr;
49 
50  //----------------------------------------------------------
51  // Use high-order AR coefficients in place of data
52  // to fit desired order MA model
53 
54  double dummy_var;
55  this->B_Coeffs = new T[est_ma_order + 1];
56 
57  yw_ptr = new YuleWalker<T>(a_coeffs, durbin_ar_order + 1, est_ma_order,
58  this->B_Coeffs, &dummy_var, &err_stat);
59 
60  delete yw_ptr;
61  delete[] a_coeffs;
62  return;
63 }
64 
65 //------------------------------------
66 // Explicit instantiations
67 template class MaEstimate<type_of_sig_vals_T>;
68 // template class MaEstimate<complex>;
int Ma_Order
Definition: ma_proc.h:26
MaEstimate(int ma_order, int durbin_ar_order, T *sig_2, int seq_len)
Definition: ma_est.cpp:25
T * Old_Input
Definition: ma_proc.h:28
std::ofstream DebugFile
T * B_Coeffs
Definition: ma_proc.h:27
double Drv_Noise_Var
Definition: ma_proc.h:30
long Noise_Seed
Definition: ma_proc.h:29