Function to calculate Standard Deviation

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: Function to calculate Standard Deviation

Post by SALINETAS24 »

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 ?
Hola, imagino que serán los mismo que en la función amStdDev.., aqui te los paso.

amStdDev(aArray,nElem,bCondition)

aArray es una Matriz multi
nElem, es la posión que ocupa el elemento de matriz que se utilizara.
bConditión, Bloque de código Opcional.

Code: Select all

  Ejemplos:
  ---------
   ? "El tamaño total del archivo aquí es"
   ?? AMSUM (DIRECTORIO (), 2)

   ? "El tamaño total del archivo .EXE aquí es"
   ?? AMSUM (DIRECTORIO (), 2, {| e | ".EXE" $ e [1]})

   ?"Desviación Estándar:"
   ?? AMSTDDEV (DIRECTORIO (), 2, {| e | ".EXE" $ e [1]})
https://vivaclipper.wordpress.com/2013/ ... _amstddev/

Un saludo virtual en una mano y en la otra una cervecita fresquita!!!
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
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 »

Disculpá... no me di cuenta que la segunda función llamaba a una tercera :oops:

FUNCTION amAverage(a,nElem,bCondition)
local nRet := 0
if (valtype(nElem) == 'N')
nRet := amSum(a,nElem,bCondition)
nRet := (nRet/aMatches(a,bCondition) )
endif
return (nRet)

La primera función " amStdDev () " devuelve la raiz cuadrada del resultado de la segunda función " amVariance () "
que a su vez promedia el valor con esta tercera " amAverage () " función.

Sólo debes darle los parámetros a la primera función y ella se los pasa a las otras dos.

Yo sólo extraje las funciones que necesitás de la librería " Superlib " para que no necesites incluirla completa.

Eng:
I'm sorry... i forgot one more function called from " amStdDev () " :oops:
This show above.
First function " amStdDev () " return square root from " amVariance () " this function receive average from " amAverage () "
You only need put parameters when call " amStdDev () ", other two received from this.
I only extract the functions you need from original " Superlib " library.
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 »

amAverage () también llama a otra función: amSum () que copio abajo

FUNCTION amSum(a,nElem,bCondition)
local nRet := 0
local i
if (valtype(nElem) == 'N')
bCondition := iif(valtype(bCondition) == 'B',bCondition,{||.t.})
for i := 1 to len(a)
if (eval(bCondition,a))
nRet+= a[nElem]
endif
next
endif
return (nRet)

Este conjunto de funciones con sus ejemplos de utilización están en " s_amstat.prg " de " Superlib "
Puedes copiar ese .prg a la carpeta de tu proyecto y luego desde el IDE incluir ese módulo
que contiene las cuatro funciones.

Eng:
All four functions here in " s_amstat.prg " to " Superlib "
Can copy " s_amstat.prg " in you project folder and include this module from IDE.
If you no have this lib i send.
I hope no infrict any copyright with this
Attachments
s_amstat.prg.zip
(1.3 KiB) Downloaded 100 times
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
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Function to calculate Standard Deviation

Post by danielmaximiliano »

Hola a Todos: compile Superlib con los archivos que estan en C:\Harbour\extras\superlib
2020-11-28 22_39_14-superlib.png
2020-11-28 22_39_14-superlib.png (8.9 KiB) Viewed 1725 times
dejo los archivos y la lib
2020-11-28 22_43_45-mingw.png
2020-11-28 22_43_45-mingw.png (2.4 KiB) Viewed 1725 times
superlib.rar
(1.82 MiB) Downloaded 113 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

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

Re: Function to calculate Standard Deviation

Post by RPC »

danielmaximiliano wrote: Sat Nov 28, 2020 1:53 pm
Se supone que para sacar un promedio necesitamos los valores (aArray) y sobre cuantos elementos (nElements)
[/quote]
Thanks Daniel.
Ok now I get it. Its length of aArray.
RPC
Posts: 284
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post by RPC »

SALINETAS24 wrote: Sat Nov 28, 2020 9:05 pm
Thanks for the explanation SALINETAS24
Last edited by RPC on Sun Nov 29, 2020 5:52 am, edited 1 time in total.
RPC
Posts: 284
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post by RPC »

Claudio Ricardo wrote: Sat Nov 28, 2020 10:46 pm
Thanks Claudio , Now it is complete.
RPC
Posts: 284
Joined: Fri Feb 10, 2017 4:12 am
DBs Used: DBF

Re: Function to calculate Standard Deviation

Post by RPC »

danielmaximiliano wrote: Sun Nov 29, 2020 1:46 am Hola a Todos: compile Superlib con los archivos que estan en C:\Harbour\extras\superlib
2020-11-28 22_39_14-superlib.png

dejo los archivos y la lib
2020-11-28 22_43_45-mingw.png
superlib.rar
Hi Daniel
Great ! Now I got libsuperlib.a .

But where do I put it ?
I have put it at following places

C:\hmg.3.4.4\HARBOUR\lib\win\mingw
C:\hmg.3.4.4\MINGW\lib
C:\hmg.3.4.4\lib

I have also put in Configuration tab of IDE
libs=libsuperlib

Still it doesn't get linked. :o :( My error.log shows as follows

hbmk2: Linking... msbktest.exe
C:/hmg.3.4.4/mingw/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibsuperlib
collect2.exe: error: ld returned 1 exit status
hbmk2[msbktest]: Error: Running linker. 1
gcc.exe .hbmk/win/mingw/msbktest.o .hbmk/win/mingw/_hbmkaut_msbktest.o "E:/RPC/SSHEETS/21/Chavan/MS-Test/_temp.o" -pthread -static-libgcc -static-libstdc++ -static -lpthread -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbmysql -lmysql -lhbfimage -lhbpgsql -lsddmy -lhbvpdf -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbtip -lsqlite3 -lhbsqlit3 -lsddodbc -lrddsql -lhbodbc -lodbc32 -lhbhpdf -lhbnetio -lxhb -lpng -llibhpdf -lhbzebra -lhblibxlsxwriter -llibsuperlib -lhbextern -lhbdebug -lhbvmmt -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -omsbktest.exe -LC:/hmg.3.4.4/harbour/lib/win/mingw -LC:/hmg.3.4.4/lib


Pls advice where I need to put libsuperlib.a so that it gets linked.
Many 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 »

hbmk2 show can't find this library in: C:\hmg.3.4.4\HARBOUR\lib\win\mingw

C:/hmg.3.4.4/mingw/bin/../lib/gcc/i686-w64-mingw32/5.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -llibsuperlib

Take care to have same name... example: if library name is " libsuperlib.a " , put " libs=libsuperlib "
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
AUGE_OHR
Posts: 2062
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Function to calculate Standard Deviation

Post by AUGE_OHR »

hi,
RPC wrote: Sun Nov 29, 2020 6:28 am I have also put in Configuration tab of IDE

Code: Select all

libs=libsuperlib
normal Prefix "lib" is not used

Code: Select all

libs=superlib
have fun
Jimmy
Post Reply