function varargout = fitdist(x,distname,varargin)
%FITDIST Fit probability distribution to gpuArray data.
%   PD = FITDIST(X,DISTNAME)
%   [PDCA,GN,GL] = FITDIST(X,DISTNAME,'BY',G)
%   PD = fitdist(..., 'NAME1',VALUE1,'NAME2',VALUE2,...)
%
%   Limitations:
%   Distributions 'rician' and 'stable' are not supported for gpuArray
%   input data.
%
%   See also FITDIST, GPUARRAY.

%   Copyright 2020-2021 The MathWorks, Inc.

narginchk(2,inf);
if ~matlab.internal.datatypes.isScalarText(distname)
    error(message("stats:fitdist:BadDist"));
end

% Check for unsupported distributions. Note that we list those *not*
% supported rather than those supported so that the normal FITDIST code can
% deal with distributions names that are invalid rather than unsupported.
% Multiple names on one line indicate aliases for one distribution.
unsupported = [
    "rician"
    "stable"
    ];
if any(startsWith(unsupported, distname, "IgnoreCase", true))
    error(message("stats:gpu:FitDistUnsupportedDistribution", distname))
end

% Now just call the standard function
varargout = cell(1,max(1,nargout));
[varargout{:}] = parallel.internal.array.callToolboxFunction( ...
    'stats/stats/fitdist', x, distname, varargin{:});
