Add flag parameter to Kurtosis in a varfun argument

1 view (last 30 days)
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?

Answers (1)

Ashutosh Singh Baghel
Ashutosh Singh Baghel on 16 Nov 2021
Edited: Ashutosh Singh Baghel on 17 Nov 2021
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.
% 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'.




Community Treasure Hunt

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

Start Hunting!

Translated by