b-k / apophenia

A C library for statistical and scientific computing
http://apophenia.info
199 stars 31 forks source link

toy example `census.c` crashing #43

Open chrplr opened 3 years ago

chrplr commented 3 years ago

Hello,

I've just installed apophenia on my system running Ubuntu 20.04 (libgsl23).

The first example, census.c from the page http://apophenia.info/gentle.html, compiles well:

$ make census cc -Wall -Wextra -g census.c -lapophenia -lgsl -lgslcblas -lsqlite3 -o census census.c: In function ‘main’: census.c:7:5: warning: missing initializer for field ‘output_pipe’ of ‘variadic_type_apop_model_print’ {aka ‘struct ’} [-Wmissing-field-initializers] 7 | apop_model_print(est); | ^~~~ In file included from census.c:1: /usr/local/include/apop.h:452:2: note: ‘output_pipe’ declared here 452 | apop_varad_declare(void, apop_model_print, apop_model model; FILE output_pipe); | ^~~~~~

But I get an error when running it:

$ ./census gsl: ../gsl/gsl_vector_double.h:180: ERROR: index out of range Default GSL error handler invoked.

which I tracked, with gdb, to:

apop_ols.c:166 ll += logl(gsl_ran_gaussian_pdf(gsl_vector_get(errors, i), sigma) weight x_prob);

JoaquinIglesiasTurina commented 2 years ago
double error_i = apop_data_get(pred, i, 2);
ll += logl(gsl_ran_gaussian_pdf(error_i, sigma)* weight * x_prob);

I've found this work around.

However, since the pred dataframe does not get mutated during the log likelihood computation, I think my work around suffices. I've noticed that the issue should be solved on the master branch, but not on pkg, which is the one recommended to install. Also I fail to install master