Add flag parameter to Kurtosis in a varfun argument

조회 수: 2 (최근 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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by