From 5834ed4446a73b58462dfe90ea80cd6d3f37d4a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 11 Dec 2015 11:50:50 +0100 Subject: [PATCH] Added checks for the input arguments of wblinv routine. --- matlab/missing/stats/wblinv.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/matlab/missing/stats/wblinv.m b/matlab/missing/stats/wblinv.m index 04f2fc593..93ac84ffa 100644 --- a/matlab/missing/stats/wblinv.m +++ b/matlab/missing/stats/wblinv.m @@ -27,6 +27,25 @@ function t = wblinv(proba, scale, shape) % --*-- Unitary tests --*-- % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . +% Check input arguments. + +if nargin<3 + error('Three input arguments required!') +end + +if ~isnumeric(proba) || ~isscalar(proba) || ~isreal(proba) || proba<0 || proba>1 + error('First input argument must be a real scalar between 0 and 1 (probability)!') +end + +if ~isnumeric(scale) || ~isscalar(scale) || ~isreal(scale) || scale<=0 + error('Second input argument must be a real positive scalar (scale parameter of the Weibull distribution)!') +end + +if ~isnumeric(shape) || ~isscalar(shape) || ~isreal(shape) || shape<=0 + error('Third input argument must be a real positive scalar (shape parameter of the Weibull distribution)!') +end + + if proba<2*eps() t = 0; return