Patterns in static

Apophenia

Setting up

The supporting cast

To use Apophenia, you will need to have a working C compiler, the GSL (v1.7 or higher) and SQLite installed.

sudo apt-get install make gcc libgsl0-dev libsqlite3-dev

or

sudo yum install make gcc gsl-devel libsqlite3x-devel
tar xvzf apop*tgz && cd apophenia-0.999
./configure && make && sudo make install && make check

If you decide not to keep the library on your system, run sudo make uninstall from the source directory to remove it.

Sample programs

Here is a sample program so you can test your setup. There is another short, complete program in the apop_ols entry which runs a simple OLS regression on a data file. Follow the instructions there to compile and run.

The sample program here is intended to show how one would integrate Apophenia into an existing program. For example, say that you are running a simulation of two different treatments, or say that two sensors are posting data at regular intervals. You need to gather the data in an organized form, and then ask questions of the resulting data set. Below, a thousand draws are made from the two processes and put into a database. Then, the data is pulled out, some simple statistics are compiled, and the data is written to a text file for inspection outside of the program. This program will compile cleanly with the sample Makefile.

#include <apop.h>
//Your processes are probably a bit more complex.
double process_one(gsl_rng *r){
return gsl_rng_uniform(r) * gsl_rng_uniform(r) ;
}
double process_two(gsl_rng *r){
return gsl_rng_uniform(r);
}
int main(){
double p1, p2;
int i;
gsl_rng *r = apop_rng_alloc(123);
//create the database and the data table.
apop_db_open("runs.db");
apop_table_exists("samples", 'd'); //If the table already exists, delete it.
apop_query("create table samples(iteration, process, value); begin;");
//populate the data table with runs.
for (i=0; i<1000; i++){
p1 = process_one(r);
p2 = process_two(r);
apop_query("insert into samples values(%i, %i, %g);", i, 1, p1);
apop_query("insert into samples values(%i, %i, %g);", i, 2, p2);
}
apop_query("commit;"); //the begin-commit wrapper saves writes to the drive.
//pull the data from the database, converting it into a table along the way.
apop_data *m = apop_db_to_crosstab("samples", "iteration","process", "value");
gsl_vector *v1 = Apop_cv(m, 0); //get vector views of the two table columns.
gsl_vector *v2 = Apop_cv(m, 1);
//Output a table of means/variances, and t-test results.
printf("\t mean\t\t var\n");
printf("process 1: %f\t%f\n", apop_mean(v1), apop_var(v1));
printf("process 2: %f\t%f\n\n", apop_mean(v2), apop_var(v2));
printf("t test\n");
apop_data_print(m, "the_data.txt");
}

Autogenerated by doxygen on Wed Oct 15 2014 (Debian 0.999b+ds3-2).