From 652da6e24cc847be425b04b6b0a8f885198785ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 5 Jun 2018 19:46:09 +0200
Subject: [PATCH] Octave 4.4 no longer includes statistics functions

Those have been moved to the statistics package. If that package is not there,
use a fallback.

(cherry picked from commit 933ed45ead196d0805feead898358c3cc7892d49)
---
 matlab/dynare_config.m | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index 787139ec7..ddacb977c 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -75,16 +75,11 @@ p = {'/distributions/' ; ...
 % For functions that exist only under some Octave versions
 % or some MATLAB versions, and for which we provide some replacement functions
 
+% Replacements for rows(), columns(), vec() and issquare() (inexistent under MATLAB)
 if ~isoctave
-    % Replacements for rows(), columns() and issquare() (inexistent under MATLAB)
     p{end+1} = '/missing/rows_columns';
     p{end+1} = '/missing/issquare';
-    % Replacement for vec() (inexistent under MATLAB)
     p{end+1} = '/missing/vec';
-    if ~user_has_matlab_license('statistics_toolbox')
-        % Replacements for functions of the stats toolbox
-        p{end+1} = '/missing/stats/';
-    end
 end
 
 % ordeig() doesn't exist in Octave
@@ -118,6 +113,13 @@ if (isoctave && ~user_has_octave_forge_package('statistics')) ...
     p{end+1} = '/missing/nanmean';
 end
 
+% Replacements for functions of the MATLAB statistics toolbox
+% These functions were part of Octave < 4.4, they are now in the statistics Forge package
+if (isoctave && ~octave_ver_less_than('4.4') && ~user_has_octave_forge_package('statistics')) ...
+        || (~isoctave && ~user_has_matlab_license('statistics_toolbox'))
+    p{end+1} = '/missing/stats/';
+end
+
 % Check if struct2array is available.
 if ~exist('struct2array')
     p{end+1} = '/missing/struct2array';
-- 
GitLab