Function to calculate Standard Deviation

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

RPC
Posts: 285
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Function to calculate Standard Deviation

Post 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
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Function to calculate Standard Deviation

Post 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/
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Function to calculate Standard Deviation

Post 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
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
RPC
Posts: 285
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post 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.
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Function to calculate Standard Deviation

Post by danielmaximiliano »

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
RPC
Posts: 285
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post 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
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Function to calculate Standard Deviation

Post 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 :oops:
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Function to calculate Standard Deviation

Post 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.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
RPC
Posts: 285
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post 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 ?
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Function to calculate Standard Deviation

Post 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)
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Post Reply