The supporting cast
To use Apophenia, you will need to have a working C compiler, the GSL (v1.7 or higher) and SQLite installed.
- Some readers are unfamiliar with modern package managers and common methods for setting up a C development environment; see Appendix O of Modeling with Data for an introduction.
- Other pages on this site have a few more notes for Windows users or MinGW users.
- Install the basics using your package manager. E.g., try
sudo apt-get install make gcc libgsl0-dev libsqlite3-dev
or
sudo yum install make gcc gsl-devel libsqlite3x-devel
- Once you have the library downloaded, compile it using
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.
- A Makefile will help immensely when you want to compile your program.
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.
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;
apop_query(
"create table samples(iteration, process, value); begin;");
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);
}
printf("\t mean\t\t var\n");
printf("t test\n");
}