Central normalized moment

Do I have to type all of the following stuff for the central moment of a random variable by hand,
or is it partly generated automatically somehow ? Or even present in LO by default from the origin ?

REM  *****  BASIC  *****

Function centralNormalizedMoment(pSequence, pOrder, Optional pIsSample As Boolean) As Double
If IsMissing(pIsSample) Then pIsSample = True
fa = CreateUnoService("com.sun.star.sheet.FunctionAccess")
N = Ubound(pSequence)
mu = fa.callFunction("AVERAGE", Array(pSequence))
useVar = fa.callFunction("VARP", Array(pSequence)) * IIf(pIsSample, N/(N - 1), 1)
useSD = Sqr(useVar)
nFactor = 1 / useSD
For j = 1 To N
  pSequence(j, 1) = ((pSequence(j, 1) - mu)*nFactor)^pOrder
Next j
prelim = fa.callFunction("AVERAGE", Array(pSequence))
If pIsSample Then
For k = 1 To pOrder - 1
  prelim = prelim * N / (N-k) 
Next k
End If
centralNormalizedMoment = prelim
End Function

Function generalNormalizedMoment(pSequence, pOrder, pFocus, Optional pIsSample As Boolean)
REM No responsibility taken! Errors expected! No responsibility taken! Errors expected!
If IsMissing(pIsSample) Then pIsSample = True
fa = CreateUnoService("com.sun.star.sheet.FunctionAccess")
N = Ubound(pSequence)
ct = fa.callFunction("COUNT", Array(pSequence))
If ct<N Then
  generalNormalizedMoment = "only:numbers:allowed"
  Exit Function
End If
mu = fa.callFunction("AVERAGE", Array(pSequence))
If TypeName(pFocus)="String" Then REM Any string interpreted as "central".
  pFocus = mu
End If
useVar = fa.callFunction("VARP", Array(pSequence)) * IIf(pIsSample, N/(N - 1), 1)
useSD = Sqr(useVar)
nFactor = 1 / useSD
For j = 1 To N
  pSequence(j, 1) = ((pSequence(j, 1) - pFocus)*nFactor)^pOrder
Next j
moment = fa.callFunction("AVERAGE", Array(pSequence))
If pIsSample Then
For k = 1 To pOrder - 1
  moment = moment * N / (N-k) 
Next k
End If
generalNormalizedMoment = moment
End Function

No - paste the functions into the BASIC IDE after you have followed the answer to Standard basic library-where can I find it ? just like you pasted to this page (it really starts getting ridiculous).

Your question is unreadable. Learn how to format things here: either use double Enter to separate lines or prefix every line with at least 4 spaces to get preformatted text. Do that with an edit of the question.

You were also already told that tag math relates to the formula editor Math, not to mathematical issues. This triggers spurious notifications on my system. So, please, retag to remove it.

Remember we are just other users with our own business. We can’t afford to reword and reformat questions for you. Help yourself to get helped by following the rules and trying to provide useful information.

For source code select the code and hit Ctrl+K to indent a block by 4 spaces which formats it as a code block.

@max2:
Again you did neither link to your related previous questions, nor mention my authorship concerning the code.
To all readers: I want to add this DISCLAIMER:
I don’t claim in the least to be an expert concerning statistics, not to speak of “higher moments” which I personally never used. The above posted code was provided “as is” without a guarantee of any kind, assuming the user (questioner) would check it thoroghly for its usability and correctness concerning the actual purpose which never was clearly stated.

@Lupp

OK, sorry for not mentioning your name. Why your

=CENTRALNORMALIZEDMOMENT(A$1:A$20; 4) 

is not equal to this:

=AVERAGE((($A$1:$A$20 - AVERAGE($A$1:$A$20))/STDEVP(A$1:A$20))^4)

?

(You insist on misunderstanding my motives.)

The formula =AVERAGE((($A$1:$A$20 - AVERAGE($A$1:$A$20))/STDEVP(A$1:A$20))^4) would need to be entered for array-evaluation to produce the correct result.

To do it this way isn’t recommendable. Use helper cells for the average and for the standard deviation, say H1 and H2 respectively. Then you get a reasonable and readable formula:
=AVERAGE((($A$1:$A$20 - $H$1)/$H$2)^4) or =AVERAGE(($A$1:$A$20 - $H$1)^4) / $H$2^4.
(Again to enter for array-evaluation by Ctrl+Shift+Enter.)
If an inner function is eligible for array-evaluation, a nested formula would fail in a ticklish way.

(I would actually prefer to leave this sequence of topics now.)

@Lupp

I have a last question: for my data A1:A20 like this
95
98
98
105
111
115
109
103
103
103
103
101
95
100
102
107
109
104
95
100

 =AVERAGE((($A$1:$A$20 - $H$2)/$H$1)^4)

gives 2,6462 but your

=CENTRALNORMALIZEDMOMENT(A$1:A$20; 4)

3,2861

Which one is correct ? Here H1 is 5,31601 and H2 is 102,8.

This depends.

The first formula assumes the given sequence to be the complete population (in terms of statistics).
You had used the STDEVP() function in your formula, where nested calculation of the later value of $H$2 was included. Assuming you did so consciously, this means you need to also tell the user function CENTRALNORMALIZEDMOMENT() to not regard the sequence a sample - but the population.

Reading the code you will easily find that this function assumes pIsSample as True by default if the third parameter is omitted. Saying “no” to the default assumption explcitly by placing a 0 on that optional parameter position, you ordered actually the same calculation as by the other formula.
(You needn’t tell me that you now get the same result.)

Once again: You pesronally and only you are responsible for whatever you conclude from the results of your sheets. (I don’t feel sure you know what you are doing.)