Add flag parameter to Kurtosis in a varfun argument

1 回表示 (過去 30 日間)
Nan Sun
Nan Sun 2021 年 11 月 6 日
編集済み: Ashutosh Singh Baghel 2021 年 11 月 17 日
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 月 16 日
編集済み: 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 Center および File ExchangeTables についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by