Add flag parameter to Kurtosis in a varfun argument

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Ashutosh Singh Baghel
Ashutosh Singh Baghel il 16 Nov 2021
Modificato: Ashutosh Singh Baghel il 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.
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'.

Categorie

Scopri di più su Tables in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by