Commit 76bdb9f9 authored by Jerome Benoit's avatar Jerome Benoit

Imported Upstream version 0.999a

parents
Ben Klemens (fluffmail@f-m.fm)
This diff is collapsed.
This software is licensed under the GNU GPL v2, with two modifications,
as follows:
--An application hosted on a server and remotely operated by users, such
as a web application or database server, is understood to be distribution
of the software, and therefore all GPL v2 clauses regarding distribution
apply. For example, a web application must include a link for downloading
the application source code.
--You are explicitly granted permission to link this software to other
code licensed under other licenses, such as GPL v3 or the BSD license.
Linking to a differently-licensed code base does not free this code (or
the combination) of the stipulations of the GPLv2 plus the above clause.
This diff is collapsed.
This diff is collapsed.
AM_CFLAGS = -g -Wall -O3 $(SQLITE_CFLAGS) $(MYSQL_CFLAGS) $(OPENMP_CFLAGS)
AM_LDFLAGS = $(SQLITE_LDFLAGS) $(OPENMP_CFLAGS) $(MYSQL_LDFLAGS)
CC = $(PTHREAD_CC)
ACLOCAL_AMFLAGS=-I m4
lib_LTLIBRARIES = libapophenia.la
libapophenia_la_SOURCES = \
apop_arms.c apop_asst.c apop_bootstrap.c apop_conversions.c \
apop_data.c apop_db.c apop_fexact.c apop_hist.c \
apop_linear_algebra.c apop_linear_constraint.c apop_mapply.c \
apop_mcmc.c apop_missing_data.c apop_mle.c apop_model.c \
apop_name.c apop_output.c apop_rake.c \
apop_regression.c apop_settings.c apop_smoothing.c apop_sort.c \
apop_stats.c apop_tests.c apop_update.c apop_vtables.c \
asprintf.c \
transform/apop_dcompose.c \
transform/apop_dconstrain.c transform/apop_fix_params.c \
transform/apop_coordinate_transform.c \
transform/apop_mixture.c transform/apop_stack.c \
model/apop_bernoulli.c model/apop_beta.c \
model/apop_dirichlet.c \
model/apop_exponential.c model/apop_gamma.c \
model/apop_histogram.c model/apop_loess.c \
model/apop_multinomial.c model/apop_multivariate_normal.c \
model/apop_normal.c model/apop_ols.c \
model/apop_pmf.c model/apop_poisson.c \
model/apop_probit.c model/apop_t.c \
model/apop_uniform.c model/apop_wishart.c \
model/apop_yule.c model/apop_zipf.c
include_HEADERS = apop.h
pkgconfig_DATA= apophenia.pc
pkgconfigdir = `pkg-config --variable pc_path pkg-config | cut -f1 -d:`
SUBDIRS=. tests
#The programs
bin_PROGRAMS = apop_text_to_db apop_db_to_crosstab apop_plot_query
apop_text_to_db_SOURCES = cmd/apop_text_to_db.c
apop_db_to_crosstab_SOURCES = cmd/apop_db_to_crosstab.c
apop_plot_query_SOURCES = cmd/apop_plot_query.c
apop_text_to_db_LDADD = libapophenia.la
apop_db_to_crosstab_LDADD = libapophenia.la
apop_plot_query_LDADD = libapophenia.la
VPATH= @srcdir@
EXTRA_DIST = docs/doxyconfig $(srcdir)/docs/*.png $(srcdir)/docs/*.gif \
$(srcdir)/docs/*.js \
docs/edit_group $(srcdir)/docs/*.html docs/typical.css \
docs/make_model_doc.awk docs/documentation.h rpm.spec \
eg apop_db_mysql.c apop_db_sqlite.c \
apop_internal.h COPYING2 apophenia.pc
DISTCLEANFILES = apophenia.pc* apophenia-uninstalled.pc apophenia-uninstalled.sh tests/*dat* tests/printing_sample 1
%.c: %.m4.c
m4 -P prep_variadics.m4 $< > $@
%.h: %.m4.h
m4 -P prep_variadics.m4 $< > $@
#The Doxygen documentation, which you'll have to call yourself (via make doc).
doc:
-rm tests/apophenia/*h
cat model/*.c transform/*.c | awk -f docs/make_model_doc.awk > docs/model_doc.h
doxygen docs/doxyconfig
cp docs/flake.gif docs/search.gif docs/right.png docs/down.png html/
@sed -i -e 's|Outlineheader \([^ ]*\)\(.*\)</p>|<h2><a class="anchor" name="\1"><div class="trigger" onClick="showBranch('\''\1d'\'');swapFolder('\''\1f'\'')"><img src="right.png" border="0" id="\1f" alt="pip">\2</div></a></h2><div class="branch" id="\1d">|' \
-e 's|endofdiv</p>|</div>|' \
-e 's|ALLBUTTON|<span class="trigger" onClick="showAll();"<a>Expand all </a></span> \| <span class="trigger" onClick="closeAll();"<a>Collapse all </a></span>|' html/index.html html/outline.html
@sed -i -e '/index_x/s/- x -/ /' -e '/index_a/s/- a -/ /' -e '/Here is a list of all/d' -e '/<span>[a-z]<\/span><\/a><\/li>/d' html/globals.html
@sed -i -e '/div class="contents"/aSee also the <a class="el" href="group__models.html">models</a> and <a class="el" href="group__settings.html">settings</a> pages.' html/globals.html
@sed -i 's|<td width="100%"></td>||g' html/*html
@sed -i -f docs/edit_group html/group__models.html
cp docs/*js html/
sudo cp man/man3/* /usr/share/man/man3/
install-data-local:
@echo
@echo "OK. If you'd like to generate documentation via Doxygen, run make doc; to test, run make check."
@echo
This diff is collapsed.
This diff is collapsed.
Apophenia is an open statistical library for working with data sets and statistical or simulation models. It provides functions on the same level as those of the typical stats package (such as OLS, probit, or singular value decomposition) but gives the user more flexibility to be creative in model-building. Being in C, it is often an order of magnitude faster when searching for optima or running MCMC chains. The core functions are written in C, but experience has shown them to be easy to bind to Python/Julia/Perl/Ruby/&c.
http://apophenia.info/gentle.html provides an overview of the basics of using the library. If you want to know more about the package, see the web site, http://apophenia.info, or have a look at the textbook from Princeton University Press that coevolved with Apophenia, downloadable from http://modelingwithdata.org .
The quick summary for installation:
∙ The library depends on the GNU Scientific Library and SQLite3. If you are using a system with a package manager of some sort, there is certainly a package for them. Be sure to include both the main package and the lib-, -dev, or -devel package. Sample package manager calls:
sudo apt-get install make gcc libgsl0-dev libsqlite3-dev
or
sudo yum install make gcc gsl-devel libsqlite3x-devel
or
sudo pacman -S make gcc gsl sqlite
∙ The prebuilt package, that has only basic prerequisites (no Autotools or m4) can be downloaded from another Git branch:
#Download the zip file, via wget or your preferred downloading method:
wget https://github.com/b-k/Apophenia/archive/pkg.zip
#unzip and build
unzip pkg.zip
cd Apophenia-pkg
./configure
make
sudo make install
Or check out the branch via git:
git clone https://github.com/b-k/Apophenia.git
cd Apophenia
git checkout pkg
./configure
make
sudo make install
∙ This master branch of the git repository requires Autotools, so it can build the
package. Try (apt-get || yum install) autoconf automake libtool. If you have Autotools installed, then from this branch you can run:
./configure
cd apophenia-0.999
make
sudo make install
∙ Find detailed setup instructions and some troubleshooting notes at
http://apophenia.info/setup.html .
Thanks for your interest. I do hope that Apophenia helps you learn more from your data.
--BK
PS: Lawyers, please note that COPYING and COPYING2 files can be found in the install/ directory.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* These are functions used here and there to write Apophenia. They're
not incredibly useful, or even very good form, so they're not public. Cut
& paste `em into your own code if you'd like.
*/
/* Many Apop functions try to treat the vector and matrix equally, which
requires knowing which exists and what the sizes are. */
#define Get_vmsizes(d) \
int firstcol = d && (d)->vector ? -1 : 0; \
int vsize = d && (d)->vector ? (d)->vector->size : 0; \
int wsize = d && (d)->weights ? (d)->weights->size : 0; \
int msize1 = d && (d)->matrix ? (d)->matrix->size1 : 0; \
int msize2 = d && (d)->matrix ? (d)->matrix->size2 : 0; \
int tsize = vsize + msize1*msize2; \
int maxsize = GSL_MAX(vsize, GSL_MAX(msize1, d?d->textsize[0]:0));\
(void)(tsize||wsize||firstcol||maxsize) /*prevent unused variable complaints */;
// Define a static variable, and initialize on first use.
#define Staticdef(type, name, def) static type (name) = NULL; if (!(name)) (name) = (def);
// Check for NULL and complain if so.
#define Nullcheck(in, errval) Apop_assert_c(in, errval, apop_errorlevel, "%s is NULL.", #in);
#define Nullcheck_m(in, errval) Apop_assert_c(in, errval, apop_errorlevel, "%s is a NULL model.", #in);
#define Nullcheck_mp(in, errval) Nullcheck_m(in, errval); Apop_assert_c((in)->parameters, errval, apop_errorlevel, "%s is a model with NULL parameters. Please set the parameters and try again.", #in);
#define Nullcheck_d(in, errval) Apop_assert_c(in, errval, apop_errorlevel, "%s is a NULL data set.", #in);
//And because I do them all so often:
#define Nullcheck_mpd(data, model, errval) Nullcheck_m(model, errval); Nullcheck_p(model, errval); Nullcheck_d(data, errval);
//deprecated:
#define Nullcheck_p(in, errval) Nullcheck_mp(in, errval);
//in apop_conversions.c Extend a string.
void xprintf(char **q, char *format, ...);
#define XN(in) ((in) ? (in) : "")
//For a pedantic compiler. Continues on error, because there's not much else to do: the computer is clearly broken.
#define Asprintf(...) Apop_stopif(asprintf(__VA_ARGS__)==-1, , 0, "Error printing to a string.")
#include <sqlite3.h>
#include <stddef.h>
int apop_use_sqlite_prepared_statements(size_t col_ct);
int apop_prepare_prepared_statements(char const *tabname, size_t col_ct, sqlite3_stmt **statement);
char *prep_string_for_sqlite(int prepped_statements, char const *astring);//apop_conversions.c
void apop_gsl_error(char const *reason, char const *file, int line, int gsl_errno); //apop_linear_algebra.c
//For when we're forced to use a global variable.
#undef threadlocal
#if __STDC_VERSION__ > 201100L
#define threadlocal _Thread_local
#elif defined(__APPLE__)
#define threadlocal
#elif defined(__GNUC__) && !defined(threadlocal)
#define threadlocal __thread
#else
#define threadlocal
#endif
#ifdef _OPENMP
#define PRAGMA(x) _Pragma(#x)
#define OMP_critical(tag) PRAGMA(omp critical ( tag ))
#define OMP_for(...) _Pragma("omp parallel for") for(__VA_ARGS__)
#else
#define OMP_critical(tag)
#define OMP_for(...) for(__VA_ARGS__)
#endif
#include "config.h"
#ifndef HAVE___ATTRIBUTE__
#define __attribute__(...)
#endif
#ifndef HAVE_ASPRINTF
#include <stdarg.h>
//asprintf, vararg, &c
extern int asprintf (char **res, const char *format, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern int vasprintf (char **res, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0)));
#endif
#include "apop.h"
void add_info_criteria(apop_data *d, apop_model *m, apop_model *est, double ll); //In apop_mle.c
apop_model *maybe_prep(apop_data *d, apop_model *m, _Bool *is_a_copy); //in apop_mcmc, for apop_update.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/** \file apop_smoothing.c A few smoothing-type functions, like moving averages. */
/* Copyright (c) 2007 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2. */
#include "apop_internal.h"
/** Return a new vector that is the moving average of the input vector.
\param v The input vector, unsmoothed
\param bandwidth The number of elements to be smoothed.
*/
gsl_vector *apop_vector_moving_average(gsl_vector *v, size_t bandwidth){
Apop_stopif(!v, return NULL, 0, "You asked me to smooth a NULL vector; returning NULL.\n");
Apop_stopif(!bandwidth, return apop_vector_copy(v), 0, "Bandwidth must be >=1. Returning a copy of original vector with no smoothing.");
int halfspan = bandwidth/2;
gsl_vector *vout = gsl_vector_calloc(v->size - halfspan*2);
for(size_t i=0; i < vout->size; i ++){
double *item = gsl_vector_ptr(vout, i);
for (int j=-halfspan; j < halfspan+1; j ++)
*item += gsl_vector_get(v, j+ i+ halfspan);
*item /= halfspan*2 +1;
}
return vout;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: Apophenia
Description: The Apophenia library
Version: 0.999
Libs: -L${exec_prefix}/lib -lapophenia -lsqlite3 -lgsl -lgslcblas -lm
Cflags: -g -O2
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
includedir=@includedir@
Name: Apophenia
Description: The Apophenia library
Version: @VERSION@
Libs: -L@libdir@ -lapophenia @LIBS@
Cflags: @CFLAGS@
This diff is collapsed.
/** \file
Command line utility to convert a three-column table to a crosstab.*/
/*Copyright (c) 2005--2007, 2013 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2. */
#include "apop_internal.h"
#include <unistd.h>
int main(int argc, char **argv){
char c, verbose=0;
char const *msg="%s [opts] dbname table_name rows columns data\n\n"
"A command-line wrapper for the apop_db_to_crosstab function.\n"
"See Apophenia's online documentation for that function for details and tricks.\n"
"-d\tdelimiter\t\tdefault=<tab>\n"
"-v\tverbose: prints status info on stderr\n"
"-v -v\textra verbose: also print queries executed on stderr\n";
Apop_stopif(argc<5, return 1, 0, msg, argv[0]);
apop_opts.verbose=0; //so don't print queries until -v -v.
while ((c = getopt (argc, argv, "d:f:hv-")) != -1)
if (c=='d') strcpy(apop_opts.output_delimiter,optarg);
else if (c=='h'||c=='-') {printf(msg, argv[0]); exit(0);}
else if (c=='v') {
verbose++;
apop_opts.verbose++;
}
Apop_stopif(optind+4 > argc, return 1, 0, "I need five arguments past the options: database, table, row col, column col, data col");
if (verbose){
fprintf(stderr, "database:%s\ntable: %s\nrow col: %s\ncol col:%s\ndata col:%s\n---------\n",
argv[optind], argv[optind +1], argv[optind+2], argv[optind+3], argv[optind+4]);
}
apop_db_open(argv[optind]);
apop_data *m = apop_db_to_crosstab(argv[optind +1], argv[optind+2], argv[optind+3], argv[optind+4]);
apop_data_print(m);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
docs/down.png

375 Bytes

This diff is collapsed.
s/Enumeration Type Documentation/Model Documentation/
s/<h2>Enumerations/<h2>Models/
/<h2>Models/,/<h2>Functions/{
s/[{}]//
s/<br\/>$//
s/<li>enum/<li>apop_model/
s/.*>(Overview|Name|Input_format|Estimate_results|Predict|RNG|CDF|Exampe|Settings)_x[0-9].*x_//
}
s/<b>Enumerator: <\/b>//
s/<td class="memname">enum <a class="el"/<td class="memname">apop_model <a class="el"/
s/_x[0-9]*x_//g
s/model_specific/Methods are Default or Model-specific/g
s/[eE]stimate_results/Post-estimate/g
s/[iI]nput_format/Input format/g
s/[pP]arameter_format/Parameter format/g
#delete all between the two markers, but not the second marker
/name="enum-members"/,/name="func-members"/{/name="func-members"/!d}
/<div class="summary">/,/\#func-members/d
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment