Recent

Author Topic: Math functions on Dataset  (Read 363 times)

stoffman

  • New Member
  • *
  • Posts: 31
Math functions on Dataset
« on: November 23, 2020, 10:22:48 pm »
I'm looking for a unit that perform math function (MIN, MAX, STD, AVG etc.. ) on datasets. is there an open source one? or commercial ?

wp

  • Hero Member
  • *****
  • Posts: 7951
Re: Math functions on Dataset
« Reply #1 on: November 24, 2020, 11:24:00 am »
It depends on which database engine you are using. Normally there are SQL "aggregate" commands for Count, Max, Min, Sum, Avg, sometimes also StdDev etc. You can call them in the query which you need to extract data from the database. I am attaching an example based on SQLite3 which does not support StdDev, but it is easy to calculate it from the SUM command.

If you are using a simple desktop dataset like TBufDataset which does not offer SQL you must iterate through all records and calculate the values manually. It's easy -- I would not use any third-party components for this job.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

stoffman

  • New Member
  • *
  • Posts: 31
Re: Math functions on Dataset
« Reply #2 on: November 25, 2020, 07:58:40 pm »
Thanks.

I'm really looking for utility functions that calculate this stuff directly from datasets. Many of these functions are easy but there some statistical functions I need that I don't wish to re-implement if someone already did them.
I did find http://www.unilim.fr/pages_perso/jean.debord/tpmath/tpmath.htm#tpmath but I've to convert everything for the library internal representation which is cumbersome.   

 

TinyPortal © 2005-2018