Hello all, I’m working on a sketch for generating fractals and would like to replace my hand-rolled complex math functions with a “proper” library
I’ve downloaded the jar for Adobe Commons Math to “sketchbook home”/libraries/acm/library/ but I can’t see how to import the library. I’d appreciate any tips. Thanks!
Look at the bottom on how to install non-Processing libraries. I did as suggested, except I called the folder “ApacheCommonsMath”, renamed the “commons-math3-3.6.1.jar” file to the same name, made a sub-folder named “library” and put it there.
Then started the Processing IDE and selected menu: Sketch - Import library - ApacheCommonsMath.
There was a long list of imports, but probably not all are neccessary, depending on what you use.
If there are examples included with the library, I don’t know how to get those installed. I made a quick test from the statistics page:
/** Apache Commons Math test
https://commons.apache.org/proper/commons-math/userguide/stat.html
*/
import org.apache.commons.math3.stat.descriptive.*;
float[] inputArray = new float[10];
for ( int i=0; i<10; i++) {
inputArray[i] = (float) i;
}
// Get a DescriptiveStatistics instance
DescriptiveStatistics stats = new DescriptiveStatistics();
// Add the data from the array
for ( int i = 0; i < inputArray.length; i++) {
stats.addValue(inputArray[i]);
}
// Compute some statistics
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double median = stats.getPercentile(50);
println(mean);
println(std);
println(median);
exit();
Thanks a million raron. I should have read How to Install a Contributed Library myself, so apologies for that. Your solution was perfect and I am mathing away! best, Toby.