test_class.file: jtstoolkit/src/test/java/ec/tstoolkit/timeseries/regression/EasterVariableTest.java
test_class.identifier: EasterVariableTest
test_case.body: @Test
      public void testShort() {
          EasterVariable var = new EasterVariable();
          DataBlock x = new DataBlock(12), y = new DataBlock(12);
          TsPeriod start = new TsPeriod(TsFrequency.Monthly, 1980, 0);
          var.data(start, x);
  
          for (int i = 0; i < 12; ++i) {
              DataBlock yc = y.range(i, i+1);
              var.data(start, yc);
              start.move(1);
          }
          assertTrue(x.distance(y)==0);
      }
test_case.class_method_signature: EasterVariableTest.testShort()
test_case.full_signature: @Test public void testShort()
test_case.identifier: testShort
test_case.invocations: data range data move assertTrue distance
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testShort()
focal_class.declarator: EMeans_Feb = new double[]{0.00368E0, 0.002083333E0, 0.001130435E0, 0.0002727273E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0}
focal_class.modifier: private static final
focal_class.original_string: private static final double[] EMeans_Feb = new double[]{0.00368E0, 0.002083333E0, 0.001130435E0, 0.0002727273E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0,
          0E0, 0E0, 0E0, 0E0, 0E0};
focal_class.type: double[]
focal_class.var_name: EMeans_Feb
focal_class.declarator: EMeans_Mar = new double[]{0.6576E0, 0.6450833E0, 0.6311304E0, 0.6162727E0, 0.5999048E0,
          0.583E0, 0.5661053E0, 0.549E0, 0.5318824E0, 0.514625E0,
          0.4973333E0, 0.4807143E0, 0.4643077E0, 0.4476667E0, 0.4305455E0,
          0.4136E0, 0.3975556E0, 0.382E0, 0.3654286E0, 0.3483333E0,
          0.3304E0, 0.3125E0, 0.2966667E0, 0.281E0, 0.266E0}
focal_class.modifier: private static final
focal_class.original_string: private static final double[] EMeans_Mar = new double[]{0.6576E0, 0.6450833E0, 0.6311304E0, 0.6162727E0, 0.5999048E0,
          0.583E0, 0.5661053E0, 0.549E0, 0.5318824E0, 0.514625E0,
          0.4973333E0, 0.4807143E0, 0.4643077E0, 0.4476667E0, 0.4305455E0,
          0.4136E0, 0.3975556E0, 0.382E0, 0.3654286E0, 0.3483333E0,
          0.3304E0, 0.3125E0, 0.2966667E0, 0.281E0, 0.266E0};
focal_class.type: double[]
focal_class.var_name: EMeans_Mar
focal_class.declarator: EMeans_Apr = new double[]{0.33872E0, 0.3528333E0, 0.3677391E0, 0.3834545E0, 0.4000952E0,
          0.417E0, 0.4338947E0, 0.451E0, 0.4681176E0, 0.485375E0,
          0.5026667E0, 0.5192857E0, 0.5356923E0, 0.5523333E0, 0.5694545E0,
          0.5864E0, 0.6024444E0, 0.618E0, 0.6345714E0, 0.6516667E0,
          0.6696E0, 0.6875E0, 0.7033333E0, 0.719E0, 0.734E0}
focal_class.modifier: private static final
focal_class.original_string: private static final double[] EMeans_Apr = new double[]{0.33872E0, 0.3528333E0, 0.3677391E0, 0.3834545E0, 0.4000952E0,
          0.417E0, 0.4338947E0, 0.451E0, 0.4681176E0, 0.485375E0,
          0.5026667E0, 0.5192857E0, 0.5356923E0, 0.5523333E0, 0.5694545E0,
          0.5864E0, 0.6024444E0, 0.618E0, 0.6345714E0, 0.6516667E0,
          0.6696E0, 0.6875E0, 0.7033333E0, 0.719E0, 0.734E0};
focal_class.type: double[]
focal_class.var_name: EMeans_Apr
focal_class.declarator: dur_ = 6
focal_class.modifier: private
focal_class.original_string: private int dur_ = 6;
focal_class.type: int
focal_class.var_name: dur_
focal_class.declarator: type_ = Correction.Simple
focal_class.modifier: private
focal_class.original_string: private Correction type_ = Correction.Simple;
focal_class.type: Correction
focal_class.var_name: type_
focal_class.declarator: m_e
focal_class.modifier: private
focal_class.original_string: private boolean m_e, m_m;
focal_class.type: boolean
focal_class.var_name: m_e
focal_class.file: jtstoolkit/src/main/java/ec/tstoolkit/timeseries/regression/EasterVariable.java
focal_class.identifier: EasterVariable
focal_class.interfaces: implements IEasterVariable
focal_class.class_method_signature: EasterVariable.EasterVariable()
focal_class.full_signature: public  EasterVariable()
focal_class.identifier: EasterVariable
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  EasterVariable()
focal_class.class_method_signature: EasterVariable.getDuration()
focal_class.full_signature: @Override public int getDuration()
focal_class.identifier: getDuration
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getDuration()
focal_class.class_method_signature: EasterVariable.setDuration(int value)
focal_class.full_signature: @Override public void setDuration(int value)
focal_class.identifier: setDuration
focal_class.modifiers: @Override public
focal_class.parameters: (int value)
focal_class.return: void
focal_class.signature: void setDuration(int value)
focal_class.class_method_signature: EasterVariable.getType()
focal_class.full_signature: public Correction getType()
focal_class.identifier: getType
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Correction
focal_class.signature: Correction getType()
focal_class.class_method_signature: EasterVariable.setType(Correction value)
focal_class.full_signature: public void setType(Correction value)
focal_class.identifier: setType
focal_class.modifiers: public
focal_class.parameters: (Correction value)
focal_class.return: void
focal_class.signature: void setType(Correction value)
focal_class.class_method_signature: EasterVariable.hasEaster()
focal_class.full_signature: public boolean hasEaster()
focal_class.identifier: hasEaster
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean hasEaster()
focal_class.class_method_signature: EasterVariable.hasEasterMonday()
focal_class.full_signature: public boolean hasEasterMonday()
focal_class.identifier: hasEasterMonday
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean hasEasterMonday()
focal_class.class_method_signature: EasterVariable.includeEaster(boolean included)
focal_class.full_signature: public void includeEaster(boolean included)
focal_class.identifier: includeEaster
focal_class.modifiers: public
focal_class.parameters: (boolean included)
focal_class.return: void
focal_class.signature: void includeEaster(boolean included)
focal_class.class_method_signature: EasterVariable.includeEasterMonday(boolean included)
focal_class.full_signature: public void includeEasterMonday(boolean included)
focal_class.identifier: includeEasterMonday
focal_class.modifiers: public
focal_class.parameters: (boolean included)
focal_class.return: void
focal_class.signature: void includeEasterMonday(boolean included)
focal_class.class_method_signature: EasterVariable.getDescription(TsFrequency context)
focal_class.full_signature: @Override public String getDescription(TsFrequency context)
focal_class.identifier: getDescription
focal_class.modifiers: @Override public
focal_class.parameters: (TsFrequency context)
focal_class.return: String
focal_class.signature: String getDescription(TsFrequency context)
focal_class.class_method_signature: EasterVariable.data(TsPeriod start, DataBlock data)
focal_class.full_signature: @Override public void data(TsPeriod start, DataBlock data)
focal_class.identifier: data
focal_class.modifiers: @Override public
focal_class.parameters: (TsPeriod start, DataBlock data)
focal_class.return: void
focal_class.signature: void data(TsPeriod start, DataBlock data)
focal_class.class_method_signature: EasterVariable.isSignificant(TsDomain domain)
focal_class.full_signature: @Override public boolean isSignificant(TsDomain domain)
focal_class.identifier: isSignificant
focal_class.modifiers: @Override public
focal_class.parameters: (TsDomain domain)
focal_class.return: boolean
focal_class.signature: boolean isSignificant(TsDomain domain)
focal_class.superclass: extends AbstractSingleTsVariable
focal_method.body: @Override
      public void data(TsPeriod start, DataBlock data) {
          data.set(0);
          int freq = start.getFrequency().intValue();
          if ((freq != 12 && freq != 4) || dur_ < 1 || dur_ > 25) {
              return;
          }
          int n = data.getLength();
          int c = 12 / freq;
          int y0 = start.getYear();
          int p0 = start.getPosition() * c;
          if (p0 > 3) {
              p0 -= 12;
              ++y0;
          }
          // first april
          int idx = (3 - p0) / c;
          if (idx > n) {
              return;
          }
  
          double dur = dur_;
  
  
          GregorianCalendar easter = new GregorianCalendar();
          for (int y = y0; idx <= n; ++y, idx += freq) {
              easter.setTime(Utilities.easter(y).getTime());
              // DAY_OF_MONTH is 1-based
              int day = easter.get(GregorianCalendar.DAY_OF_MONTH);
              int month = easter.get(GregorianCalendar.MONTH);
              if (!m_e) {
                  --day;
              } else if (m_m) {
                  if (day == 31) {
                      day = 1;
                      ++month;
                  } else {
                      ++day;
                  }
              }
  
              // MONTH is 0-based
              double m = 0, a = 0;
              if (type_ == Correction.Simple) {
                  if (month == 2 || day == 0) {
                      m = .5;
                      a = -.5;
                  } else if (day >= dur_) {
                      m = -.5;
                      a = .5;
                  } else {
                      m = (dur - day) / dur - .5;
                      a = -m;
                  }
              } else // use long mean correction. Mean correction should be adapted
              // to take into account the new solution proposed in tramo (easter, easter monday)
              // included in the holiday
              {
                  double m_av = 0, a_av = 0;
                  if (type_ == Correction.PreComputed) {
                      m_av = EMeans_Mar[25 - dur_]; //(21 + dur) / 70.0;
                      a_av = EMeans_Apr[25 - dur_];//(49 - dur) / 70.0;
                  } else {
                      /*
                       * Raw estimation of the probability to get Easter at a specific date is defined below:
                       * 22/3 (1/7)*1/LUNARY
                       * 23/3 (2/7)*1/LUNARY
                       * ...
                       * 27/3 (6/7)*1/LUNARY
                       * 28/3 1/LUNARY
                       * ...
                       * 18/4 1/LUNARY
                       * 19/4 1/LUNARY + (1/7) * DEC_LUNARY/LUNARY = (7 + DEC_LUNARY)/(7 * LUNARY)
                       * 20/4 (6/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY = (6 + DEC_LUNARY)/(7 * LUNARY)
                       * 21/4 (5/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY
                       * 22/4 (4/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY
                       * 23/4 (3/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY
                       * 24/4 (2/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY
                       * 25/4 (1/7)*1/LUNARY + (1/7) * DEC_LUNARY/LUNARY
                       * 
                       * In comparison with long term (5700000 years) computations based on several algorithms,
                       * the error is small (< 0.0025)
                       * 
                       * The average number in march, folliwng dur (<= 15 !!!) is computed as follow:
                       * + for period 22/3 to 27/3: always in march
                       *    dur * (1/7 + ... + 6/7)/LUNARY = dur * 3 / LUNARY 
                       * + for period 28/3 to 1/4: always in march
                       *    dur * 5 / LUNARY
                       * + for period 2/4 to dur/4
                       *    (dur-1 + dur-2 + 1) / LUNARY = dur * (dur-1) / (2 * LUNARY)
                       * + for other dates: 0
                       * 
                       * Total:
                       *   dur * (6+10+dur-1)/ (2* LUNARY) = dur * 15 / (2 * LUNARY)
                       * Relative part:
                       *   15 / (2* LUNARY)
                       */
                      m_av = (15 + dur) / (2 * Utilities.LUNARY);
                      a_av = 1 - m_av;
                  }
                  if (month == 2) {
                      m = 1 - m_av;
                      a = -a_av;
                  } else if (day >= dur_) {
                      m = -m_av;
                      a = 1 - a_av;
                  } else {
                      m = (dur - day) / dur - m_av;
                      a = day / dur - a_av;
                  }
              }
  
              if (idx - 1 >= 0) {
                  data.set(idx - 1, m);
              }
              if (idx < n) {
                  data.set(idx, a);
              }
          }
      }
focal_method.class_method_signature: EasterVariable.data(TsPeriod start, DataBlock data)
focal_method.full_signature: @Override public void data(TsPeriod start, DataBlock data)
focal_method.identifier: data
focal_method.invocations: set intValue getFrequency getLength getYear getPosition setTime getTime easter get get set set
focal_method.modifiers: @Override public
focal_method.parameters: (TsPeriod start, DataBlock data)
focal_method.return: void
focal_method.signature: void data(TsPeriod start, DataBlock data)