Add flag parameter to Kurtosis in a varfun argument

1 次查看(过去 30 天)
Hi,
I am trying to calculate the kurtosis for a set of data in Matlab with the following argument:
tailedness_GEAR = varfun(@kurtosis, GEAR,0, "InputVariables", @isnumeric)
However, I would like to add a flag argument (flag=0) to the function. How am I supposed to do that?
Thanks

回答(1 个)

Ashutosh Singh Baghel
编辑:Ashutosh Singh Baghel 2021-11-17
Hi Nan Sun,
I understand that you wish to pass 'flag = 0' as an input argument to the function "kurtosis" inside the function called "varfun."
This can be done by parameterizing the function call. I have shown this in the following example -
% Correct for Bias in Sample Kurtosis
% For an input vector, correct for bias in the calculation of kurtosis by specifying the flag input argument.
% Set the random seed for reproducibility of the results.
rng('default')
% Generate a vector of length 10.
GEAR = randn(10,1);
% Find the biased kurtosis of x. By default, kurtosis sets the value of flag to 1 for computing the biased kurtosis.
k1 = kurtosis(GEAR) % flag is 1 by default
k1 = 2.3121
% Find the bias-corrected kurtosis of x by setting the value of flag to 0.
k2 = kurtosis(GEAR,0) %flag is set to 0
k2 = 2.7483
% Finding the kurtosis by passing 0 as flag using parameterizzation of functions.
tailedness_GEAR = varfun(@(x) kurtosis(x,0), table(GEAR),"InputVariables", @isnumeric)
tailedness_GEAR = table
Fun_GEAR ________ 2.7483
Also, the input table 'GEAR' is allowed as a table or timetable.
Refer to these MATLAB Documentation pages on 'varfun', and 'Parameterizing Functions'.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by