Skip to content

Commit

Permalink
replaced CubatureSmoothing option with new CubatureAcceleration optio…
Browse files Browse the repository at this point in the history
…n, based on iterating Aitken's delta squared transformation
  • Loading branch information
tholden committed Jul 20, 2017
1 parent 70671f8 commit beb8fba
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 31 deletions.
15 changes: 7 additions & 8 deletions Core/OBCSimulation/PerformCubature.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
end
end

CubatureWeights = [ [ 1; zeros( NumPoints( end ) - 1, 1 ) ], CubatureWeights ];
NumPoints = [ 1 NumPoints ];

if nargin > 6
Expand All @@ -44,13 +45,12 @@
end

yMatrix = y * CubatureWeights( 1, : );
yPure = y;

if ~isempty( p )
p.progress;
end

CubatureSmoothing = dynareOBC.CubatureSmoothing;
CubatureAcceleration = dynareOBC.CubatureAcceleration;

WarningGenerated = false;
for i = 1 : CubatureOrder
Expand Down Expand Up @@ -91,14 +91,13 @@
end
end
end

yPureNew = yMatrix( :, i );
if dynareOBC.FastCubature || ( CubatureSmoothing <= 0 ) || ( CubatureSmoothing >= 1 ) || ( dynareOBC.QuasiMonteCarloLevel > 0 )
yNew = yPureNew;

if CubatureAcceleration
yNew = IteratedAitkensDeltaSquaredTransformation( yMatrix( :, 1 : ( i + 1 ) ) );
else
yNew = ( 1 - CubatureSmoothing ) * yPureNew + CubatureSmoothing * yPure;
yNew = yMatrix( :, i + 1 );
end
yPure = yPureNew;

yError = max( abs( y - yNew ) );
y = yNew;

Expand Down
2 changes: 1 addition & 1 deletion Core/SetDefaultOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
dynareOBC = SetDefaultOption( dynareOBC, 'Bypass', false );
dynareOBC = SetDefaultOption( dynareOBC, 'CalculateTheoreticalVariance', false );
dynareOBC = SetDefaultOption( dynareOBC, 'CompileSimulationCode', false );
dynareOBC = SetDefaultOption( dynareOBC, 'CubatureAcceleration', false );
dynareOBC = SetDefaultOption( dynareOBC, 'CubaturePruningCutOff', 0.01 );
dynareOBC = SetDefaultOption( dynareOBC, 'CubatureSmoothing', -eps );
dynareOBC = SetDefaultOption( dynareOBC, 'CubatureTolerance', eps ^ 0.375 );
dynareOBC = SetDefaultOption( dynareOBC, 'DataFile', [ dynareOBC.BaseFileName '.xlsx' ] );
dynareOBC = SetDefaultOption( dynareOBC, 'Debug', false );
Expand Down
33 changes: 33 additions & 0 deletions Core/Utils/IteratedAitkensDeltaSquaredTransformation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function Seq = IteratedAitkensDeltaSquaredTransformation( Seq )

N = size( Seq, 2 );

if N >= 3

if mod( N, 2 ) == 0
Seq = Seq( :, 2:end );
N = N - 1;
end

for Idx = 1 : ( 0.5 * ( N - 1 ) )

DSeq = diff( Seq, 1, 2 );

Seq = Seq( :, 3:end );
LDSeq = DSeq( :, 1:(end-1) );
DSeq = DSeq( :, 2:end );

Adj = DSeq .* DSeq ./ ( DSeq - LDSeq );
FiniteAdj = isfinite( Adj );

Seq( FiniteAdj ) = Seq( FiniteAdj ) - Adj( FiniteAdj );

end

else

Seq = Seq( :, N );

end

end
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ Note:
* `FastCubature`
Causes DynareOBC to ignore the value specified in `MaxCubatureDegree` and `QuasiMonteCarlo`, and to instead use a degree 3 monomial cubature rule without negative weights, but involving evaluations further from the origin.
* `QuasiMonteCarloLevel=INTEGER` (default: `0`)
If this is non-zero, then Gaussian cubature is not used (so the MaxCubatureDegree option is ignored). Instead, quasi- Monte Carlo integration with at most `2^(1+INTEGER) - 1` samples is used.
If this is non-zero, then Gaussian cubature is not used (so the `MaxCubatureDegree` option is ignored). Instead, quasi-Monte Carlo integration with at most `2^(1+INTEGER) - 1` samples is used.
* `MaxCubatureDegree=INTEGER` (default: `5`)
Specifies the degree of polynomial which will be integrated exactly in the highest degree cubature performed. Values above `51` are treated as equal to `51`. Note that setting `CubatureSmoothing>0` will reduce the effective maximum accuracy by 2 degrees. Setting `CubatureTolerance>0` may also mean that the result does not integrate the stated degree polynomials exactly as well.
* `CubatureSmoothing=FLOAT_IN_UNIT_INTERVAL` (default: `0`)
When this is larger than 0, and less than 1, DynareOBC takes a weighted combination of the results of cubature rules of adjacent degrees. Large numbers imply larger weights on lower degree rules. A good setting is often 0.01 - 0.3.
Specifies the degree of polynomial which will be integrated exactly in the highest degree cubature performed. Values above `51` are treated as equal to `51`. Note that enabling the option `CubatureSmoothing` or setting `CubatureTolerance>0` may mean that the result does not integrate the stated degree polynomials exactly.
* `CubatureAcceleration`
When DynareOBC is invoked with this option, DynareOBC accelerates convergence of the cubature rules towards their limit using an iterated version of Aitken's delta-squared transformation.
* `CubaturePruningCutOff=FLOAT` (default: `0.01`)
Eigenvalues of the covariance matrix of the distribution from which we integrate that are below `FLOAT` times the maximum eigenvalue are "pruned" to zero, in order to increase integration speed.
* `MaxCubatureDimension=INTEGER` (default: `128`)
Expand Down
Binary file modified ReadMe.pdf
Binary file not shown.
16 changes: 7 additions & 9 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,16 @@ OPTIONS (NOT CASE SENSITIVE!) include:
evaluations further from the origin.
* QuasiMonteCarloLevel=INTEGER (default: 0)
If this is non-zero, then Gaussian cubature is not used (so the MaxCubatureDegree option is
ignored). Instead, quasi- Monte Carlo integration with at most 2^(1+INTEGER) - 1 samples is
ignored). Instead, quasi-Monte Carlo integration with at most 2^(1+INTEGER) - 1 samples is
used.
* MaxCubatureDegree=INTEGER (default: 5)
Specifies the degree of polynomial which will be integrated exactly in the highest degree
cubature performed. Values above 51 are treated as equal to 51. Note that setting
CubatureSmoothing>0 will reduce the effective maximum accuracy by 2 degrees. Setting
CubatureTolerance>0 may also mean that the result does not integrate the stated degree
polynomials exactly as well.
* CubatureSmoothing=FLOAT_IN_UNIT_INTERVAL (default: 0)
When this is larger than 0, and less than 1, DynareOBC takes a weighted combination of
the results of cubature rules of adjacent degrees. Large numbers imply larger weights on
lower degree rules. A good setting is often 0.01 - 0.3.
cubature performed. Values above 51 are treated as equal to 51. Note that enabling the option
CubatureSmoothing or setting CubatureTolerance>0 may mean that the result does not integrate
the stated degree polynomials exactly.
* CubatureAcceleration
When DynareOBC is invoked with this option, DynareOBC accelerates convergence of the cubature
rules towards their limit using an iterated version of Aitken's delta-squared transformation.
* CubaturePruningCutOff=FLOAT (default: 0.01)
Eigenvalues of the covariance matrix of the distribution from which we integrate that are
below FLOAT times the maximum eigenvalue are "pruned" to zero, in order to increase
Expand Down
16 changes: 7 additions & 9 deletions dynareOBC.m
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,16 @@ function dynareOBC( InputFileName, varargin )
% evaluations further from the origin.
% * QuasiMonteCarloLevel=INTEGER (default: 0)
% If this is non-zero, then Gaussian cubature is not used (so the MaxCubatureDegree option is
% ignored). Instead, quasi- Monte Carlo integration with at most 2^(1+INTEGER) - 1 samples is
% ignored). Instead, quasi-Monte Carlo integration with at most 2^(1+INTEGER) - 1 samples is
% used.
% * MaxCubatureDegree=INTEGER (default: 5)
% Specifies the degree of polynomial which will be integrated exactly in the highest degree
% cubature performed. Values above 51 are treated as equal to 51. Note that setting
% CubatureSmoothing>0 will reduce the effective maximum accuracy by 2 degrees. Setting
% CubatureTolerance>0 may also mean that the result does not integrate the stated degree
% polynomials exactly as well.
% * CubatureSmoothing=FLOAT_IN_UNIT_INTERVAL (default: 0)
% When this is larger than 0, and less than 1, DynareOBC takes a weighted combination of
% the results of cubature rules of adjacent degrees. Large numbers imply larger weights on
% lower degree rules. A good setting is often 0.01 - 0.3.
% cubature performed. Values above 51 are treated as equal to 51. Note that enabling the option
% CubatureSmoothing or setting CubatureTolerance>0 may mean that the result does not integrate
% the stated degree polynomials exactly.
% * CubatureAcceleration
% When DynareOBC is invoked with this option, DynareOBC accelerates convergence of the cubature
% rules towards their limit using an iterated version of Aitken's delta-squared transformation.
% * CubaturePruningCutOff=FLOAT (default: 0.01)
% Eigenvalues of the covariance matrix of the distribution from which we integrate that are
% below FLOAT times the maximum eigenvalue are "pruned" to zero, in order to increase
Expand Down

0 comments on commit beb8fba

Please sign in to comment.