-1- You still didn’t make clear if you want to calculate actual moments for known populations or estimator values based on samples.
-2- I personally can implement one of the formulas I find for the topic by user code, but having not done anything in the field of “higher statistics” for decades now, I cannot take any responsibility concerning the applicability under specific conditions. Not having means to at least check results of higher order than 3 (skewness) there should, of course, also implementation errors be expected.
-3- Since I don’t feel sure you can reliably decide what’s needed to get correct and meaningful results, I should not make tools for you. They might tempt you to use them without the sharp criticism they deserve.
This said, I yet post a demo document containing a user function for the purpose which I made in a playful mood.
ask275423HigherStatisticalMoments.ods
Be careful! There’s surely enough bad (evil?) statistics in the world.
===Edit 2020-11-08 about 21:40 UTC===
If this wasn’t about statistical moments, the use-case should have been clearly explained from the beginning.
The code below will calculate moments in the most primitive way. If central moments are required, the pAxis
parameter must get passed the AVERAGE of the sequence.
Function simpleGeneralMoment(pAxis As Double, pOrder As Long, pSequence)
REM No centralization, no normalization, no anythingation! No statistics at all.
REM pSequence must be data from a contiguous part of a single column.
fa = CreateUnoService("com.sun.star.sheet.FunctionAccess")
N = Ubound(pSequence)
count = fa.callFunction ("COUNT", Array(pSequence))
If count<N Then
simpleGeneralMoment = "numbers only!"
Exit Function
End If
For j = 1 To N
pSequence(j, 1) = (pSequence(j, 1)-pAxis)^pOrder
Next j
simpleGeneralMoment = fa.callFunction("AVERAGE", Array(pSequence))
End Function
The formula =SUM(($A$2:$A$21 - pAxis)^3) / COUNT($A$2:$A$21)
entered for array-evaluation would also return the third moment for your example. I just don’t know by what value (for pAxis) you want to replace the center.