Hi Paulo,
Could I make a suggestion? In the library documentation I find no mention of the specific algorithms used. It is often useful to know the properties of an algorithm one is about to use but if we don't know what the algorithm is it becomes harder to look into. By referencing the algorithm it will also be easier to check for and fix bugs. Furthermore, it is nice to give credit when possible.
I ran into this problem when using the pseudorandom number generator a few months ago, and again yesterday when using the standard deviation algorithm in the brand new descriptive statistics library. A quick glance here http://en.wikipedia.org/wiki/Algorithms ... g_variance shows that there may be problems with precision when calculating standard deviation or variance. However, without dissecting the code it is not clear what the library is doing; is it possible there will be precision problems?
The number of libraries being distributed with Logtalk is growing all the time and I want to thank you for making it an increasingly powerful and pleasant environment to develop in.
Cheers,
Parker
Documentation for libraries distributed with Logtalk
Moderator: Paulo Moura

 Logtalk developer
 Posts: 533
 Joined: Sat May 05, 2007 8:35 am
 Location: Portugal
 Contact:
Re: Documentation for libraries distributed with Logtalk
Hi Parker!
Cheers,
Paulo
That's a good idea. I toyed with something along your suggestion when developing the "statistics" library. For most calculations in this library, I had to look for and implement numerically stable algorithms. A possible solution would be to add "complexity" and "algorithm" keys to the predicate info/2 directives. Feedback appreciated.Parker wrote: Could I make a suggestion? In the library documentation I find no mention of the specific algorithms used. It is often useful to know the properties of an algorithm one is about to use but if we don't know what the algorithm is it becomes harder to look into. By referencing the algorithm it will also be easier to check for and fix bugs. Furthermore, it is nice to give credit when possible.
The variance predicate uses a numerically stable algorithm due to Knuth, described in the Wikipedia page you cite. The standard deviation uses an algorithm that provides better performance than the naive algorithm. As the calculation of the variance is different for samples and for populations, you can always calculate the appropriated variance and then take its square root to get the standard deviation. In any case, the "statistics" library is a work in progress that needs to be checked by someone knowledgeable in statistics (which Im not); the usual disclaimer applies. Contributions welcome.Parker wrote: I ran into this problem when using the pseudorandom number generator a few months ago, and again yesterday when using the standard deviation algorithm in the brand new descriptive statistics library. A quick glance here http://en.wikipedia.org/wiki/Algorithms ... g_variance shows that there may be problems with precision when calculating standard deviation or variance. However, without dissecting the code it is not clear what the library is doing; is it possible there will be precision problems?
Thanks More goodies coming in the next release (I'm currently working in conditional compilation support in order to simplify writing portable code).Parker wrote: The number of libraries being distributed with Logtalk is growing all the time and I want to thank you for making it an increasingly powerful and pleasant environment to develop in.
Cheers,
Paulo
Paulo Moura
Logtalk developer
Logtalk developer