Page 1 of 4
Function to calculate Standard Deviation
Posted: Wed Nov 25, 2020 9:32 pm
by RPC
Hi
Is there a function to calculate Standard Deviation in HMG ?
On Esgici's wonderful site Vivaclipper.com I found ASTDDEV() function but HMG throws error of undefined function.
Can anyone help me on this.
Thanks
Re: Function to calculate Standard Deviation
Posted: Wed Nov 25, 2020 10:05 pm
by mol
Find information in which library this function and include it manually.
This function is defined in SuperLib:
https://vivaclipper.wordpress.com/2013/ ... -superlib/
Re: Function to calculate Standard Deviation
Posted: Wed Nov 25, 2020 10:33 pm
by Claudio Ricardo
Hola...
Tal vez este post te ayude:
viewtopic.php?t=5392
Hi...
Maybe this post can help you:
viewtopic.php?t=5392
Re: Function to calculate Standard Deviation
Posted: Thu Nov 26, 2020 7:39 am
by RPC
Hi Mol and Claudio
Thanks for your reply.
I have SuperLib sup3552.lib. I tried linking it by putting libs=sup3552.lib in configuration tab of IDE but it doen't work.
I checked the link provided by Claudio where Esgici has advised to read readme.txt file in harbour directory.
The readme.txt file contains
4.) Apply supplied patch to the source using GNU Patch:
patch -lNi superlib.dif
from where do I get patch.exe to patch superlib.dif. Will this produce something like superlib.a library which can be linked to my program using libs=superlib.a
Pls advice.
Many thanks to both of you.
Re: Function to calculate Standard Deviation
Posted: Thu Nov 26, 2020 1:18 pm
by danielmaximiliano
Re: Function to calculate Standard Deviation
Posted: Fri Nov 27, 2020 7:32 am
by RPC
Hi Daniel
Many thanks for the link. I have downloaded the files mentioned by Vlademiro in the link.
However I still can't link superlib.lib. Can you provide a more detailed guide.
Thanks
Re: Function to calculate Standard Deviation
Posted: Fri Nov 27, 2020 8:36 am
by Claudio Ricardo
This is the function and asociated function:
FUNCTION amStdDev(aArray,nElem,bCondition)
return(sqrt(amVariance(aArray,nElem,bCondition)))
FUNCTION amVariance(aArray,nElem,bCondition)
local nAverage, i
local nVariance := 0
local nCount := 0
local nReturn := 0
if (valtype(nElem) == 'N')
nAverage := amAverage(aArray,nElem,bCondition)
bCondition := iif(valtype(bCondition) == 'B',bCondition,{||.t.})
for i := 1 to len(aArray)
if (eval(bCondition,aArray
))
nVariance += ((nAverage-aArray[nElem] )^2)
nCount++
endif
next
nReturn := (nVariance/nCount)
endif
return (nReturn)
Copy and paste in you .prg or create new module into you project and paste into... is all.
Pd Sorry for my bad eng 
Re: Function to calculate Standard Deviation
Posted: Fri Nov 27, 2020 8:49 am
by Claudio Ricardo
Call :
amStdDev (aArray,nElem,bCondition)
or can rename " FUNCTION amStdDev (aArray,nElem,bCondition) " to " FUNCTION ASTDDEV (aArray,nElem,bCondition) "
if your .prg call this function with this name.
Re: Function to calculate Standard Deviation
Posted: Sat Nov 28, 2020 7:22 am
by RPC
Hi Claudio
Thanks for the functions.
It requires amAverage(aArray,nElem,bCondition) function while compiling.
Also what is nElem value to be passed ?
Re: Function to calculate Standard Deviation
Posted: Sat Nov 28, 2020 1:53 pm
by danielmaximiliano
RPC wrote: ↑Sat Nov 28, 2020 7:22 am
Hi Claudio
Thanks for the functions.
It requires amAverage(aArray,nElem,bCondition) function while compiling.
Also what is nElem value to be passed ?
Se supone que para sacar un promedio necesitamos los valores (aArray) y sobre cuantos elementos (nElements)