Patterns in static

Apophenia

apop.h
Go to the documentation of this file.
1 
3 /* Copyright (c) 2005--2014 by Ben Klemens. Licensed under the modified GNU GPL v2; see COPYING and COPYING2. */
4 
5 /* Here are the headers for all of apophenia's functions, typedefs, static variables and
6 macros. All of these begin with the apop_ (or Apop_ or APOP_) prefix.
7 
8 There used to be a series of sub-headers, but they never provided any serious
9 benefit. Please use your text editor's word-search feature to find any elements you
10 may be looking for. About a third of the file is comments and doxygen documentation,
11 so syntax highlighting that distinguishes code from comments will also help to make
12 this more navigable.
13 
14 */
15 #pragma once
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #ifndef _GNU_SOURCE
21 #define _GNU_SOURCE //for asprintf
22 #endif
23 
24 #include <assert.h>
25 #include <signal.h> //raise(SIGTRAP)
26 #include <string.h>
27 #include <gsl/gsl_rng.h>
28 #include <gsl/gsl_matrix.h>
29 
30 
32 
33 /* A means of providing more script-like means of sending arguments to a function.
34 
35 These macros are intended as internal. See the documentation if you're interested in
36 using this mechanism in out-of-Apophenia work.
37 */
38 
39 #define apop_varad_head(type, name) type variadic_##name(variadic_type_##name varad_in)
40 
41 #define apop_varad_declare(type, name, ...) \
42  typedef struct { \
43  __VA_ARGS__ ; \
44  } variadic_type_##name; \
45  apop_varad_head(type, name);
46 
47 #define apop_varad_var(name, value) name = varad_in.name ? varad_in.name : (value);
48 #define apop_varad_link(name,...) variadic_##name((variadic_type_##name) {__VA_ARGS__})
49 
50 
51 
53 
54 
58 typedef struct{
59  char *title;
60  char * vector;
61  char ** col;
62  char ** row;
63  char ** text;
64  int colct, rowct, textct;
65 } apop_name;
66 
77 typedef struct apop_data{
78  gsl_vector *vector;
79  gsl_matrix *matrix;
80  apop_name *names;
81  char ***text;
82  size_t textsize[2];
83  gsl_vector *weights;
84  struct apop_data *more;
85  char error;
86 } apop_data;
87 
88 /* Settings groups. For internal use only; see apop_settings.c and
89  settings.h for related machinery. */
90 typedef struct {
91  char name[101];
92  unsigned long name_hash;
93  void *setting_group;
94  void *copy;
95  void *free;
97 
99 typedef struct apop_model apop_model;
100 
102 struct apop_model{
103  char name[101];
104  int vsize, msize1, msize2, dsize;
115  void (*estimate)(apop_data * data, apop_model *params);
117  long double (*p)(apop_data *d, apop_model *params);
119  long double (*log_likelihood)(apop_data *d, apop_model *params);
121  long double (*cdf)(apop_data *d, apop_model *params);
123  long double (*constraint)(apop_data *data, apop_model *params);
124  int (*draw)(double *out, gsl_rng* r, apop_model *params);
126  void (*prep)(apop_data *data, apop_model *params);
127  apop_settings_type *settings;
128  void *more;
131  size_t more_size;
133  char error;
134 };
135 
138 typedef struct{
139  int verbose;
141  char output_delimiter[100];
143  char input_delimiters[100];
144  char db_name_column[300];
145  char *nan_string;
146  char db_engine;
147  char db_user[101];
148  char db_pass[101];
149  FILE *log_file;
152  #if __STDC_VERSION__ > 201100L && !defined(__STDC_NO_ATOMICS__)
153  _Atomic(int) rng_seed;
154  #else
155  int rng_seed;
156  #endif
157  float version;
159 
161 
162 apop_name * apop_name_alloc(void);
163 int apop_name_add(apop_name * n, char const *add_me, char type);
164 void apop_name_free(apop_name * free_me);
165 void apop_name_print(apop_name * n);
166 #ifdef APOP_NO_VARIADIC
167  void apop_name_stack(apop_name * n1, apop_name *nadd, char type1, char typeadd) ;
168 #else
169  void apop_name_stack_base(apop_name * n1, apop_name *nadd, char type1, char typeadd) ;
170  apop_varad_declare(void, apop_name_stack, apop_name * n1; apop_name *nadd; char type1; char typeadd);
171 #define apop_name_stack(...) apop_varad_link(apop_name_stack, __VA_ARGS__)
172 #endif
173 
175 int apop_name_find(const apop_name *n, const char *findme, const char type);
176 
177 void apop_data_add_names_base(apop_data *d, const char type, char const ** names);
178 
200 #define apop_data_add_names(dataset, type, ...) apop_data_add_names_base((dataset), (type), (char const*[]) {__VA_ARGS__, NULL})
201 
202 
216 #define apop_data_free(freeme) (apop_data_free_base(freeme) ? 0 : ((freeme)= NULL))
217 
218 char apop_data_free_base(apop_data *freeme);
219 apop_data * apop_matrix_to_data(gsl_matrix *m); //deprecated
220 apop_data * apop_vector_to_data(gsl_vector *v); //deprecated
221 #ifdef APOP_NO_VARIADIC
222  apop_data * apop_data_alloc(const size_t size1, const size_t size2, const int size3) ;
223 #else
224  apop_data * apop_data_alloc_base(const size_t size1, const size_t size2, const int size3) ;
225  apop_varad_declare(apop_data *, apop_data_alloc, const size_t size1; const size_t size2; const int size3);
226 #define apop_data_alloc(...) apop_varad_link(apop_data_alloc, __VA_ARGS__)
227 #endif
228 
229 #ifdef APOP_NO_VARIADIC
230  apop_data * apop_data_calloc(const size_t size1, const size_t size2, const int size3) ;
231 #else
232  apop_data * apop_data_calloc_base(const size_t size1, const size_t size2, const int size3) ;
233  apop_varad_declare(apop_data *, apop_data_calloc, const size_t size1; const size_t size2; const int size3);
234 #define apop_data_calloc(...) apop_varad_link(apop_data_calloc, __VA_ARGS__)
235 #endif
236 
237 #ifdef APOP_NO_VARIADIC
238  apop_data * apop_data_stack(apop_data *m1, apop_data * m2, char posn, char inplace) ;
239 #else
240  apop_data * apop_data_stack_base(apop_data *m1, apop_data * m2, char posn, char inplace) ;
241  apop_varad_declare(apop_data *, apop_data_stack, apop_data *m1; apop_data * m2; char posn; char inplace);
242 #define apop_data_stack(...) apop_varad_link(apop_data_stack, __VA_ARGS__)
243 #endif
244 
245 apop_data ** apop_data_split(apop_data *in, int splitpoint, char r_or_c);
246 apop_data * apop_data_copy(const apop_data *in);
247 void apop_data_rm_columns(apop_data *d, int *drop);
248 void apop_data_memcpy(apop_data *out, const apop_data *in);
249 #ifdef APOP_NO_VARIADIC
250  double * apop_data_ptr(apop_data *data, int row, int col, const char *rowname, const char *colname, const char *page) ;
251 #else
252  double * apop_data_ptr_base(apop_data *data, int row, int col, const char *rowname, const char *colname, const char *page) ;
253  apop_varad_declare(double *, apop_data_ptr, apop_data *data; int row; int col; const char *rowname; const char *colname; const char *page);
254 #define apop_data_ptr(...) apop_varad_link(apop_data_ptr, __VA_ARGS__)
255 #endif
256 
257 #ifdef APOP_NO_VARIADIC
258  double apop_data_get(const apop_data *data, size_t row, int col, const char *rowname, const char *colname, const char *page) ;
259 #else
260  double apop_data_get_base(const apop_data *data, size_t row, int col, const char *rowname, const char *colname, const char *page) ;
261  apop_varad_declare(double, apop_data_get, const apop_data *data; size_t row; int col; const char *rowname; const char *colname; const char *page);
262 #define apop_data_get(...) apop_varad_link(apop_data_get, __VA_ARGS__)
263 #endif
264 
265 #ifdef APOP_NO_VARIADIC
266  int apop_data_set(apop_data *data, size_t row, int col, const double val, const char *rowname, const char * colname, const char *page) ;
267 #else
268  int apop_data_set_base(apop_data *data, size_t row, int col, const double val, const char *rowname, const char * colname, const char *page) ;
269  apop_varad_declare(int, apop_data_set, apop_data *data; size_t row; int col; const double val; const char *rowname; const char * colname; const char *page);
270 #define apop_data_set(...) apop_varad_link(apop_data_set, __VA_ARGS__)
271 #endif
272 
273 void apop_data_add_named_elmt(apop_data *d, char *name, double val);
274 int apop_text_add(apop_data *in, const size_t row, const size_t col, const char *fmt, ...);
275 apop_data * apop_text_alloc(apop_data *in, const size_t row, const size_t col);
276 void apop_text_free(char ***freeme, int rows, int cols);
277 #ifdef APOP_NO_VARIADIC
278  apop_data * apop_data_transpose(apop_data *in, char transpose_text, char inplace) ;
279 #else
280  apop_data * apop_data_transpose_base(apop_data *in, char transpose_text, char inplace) ;
281  apop_varad_declare(apop_data *, apop_data_transpose, apop_data *in; char transpose_text; char inplace);
282 #define apop_data_transpose(...) apop_varad_link(apop_data_transpose, __VA_ARGS__)
283 #endif
284 
285 gsl_matrix * apop_matrix_realloc(gsl_matrix *m, size_t newheight, size_t newwidth);
286 gsl_vector * apop_vector_realloc(gsl_vector *v, size_t newheight);
287 
288 #define apop_data_prune_columns(in, ...) apop_data_prune_columns_base((in), (char *[]) {__VA_ARGS__, NULL})
289 apop_data* apop_data_prune_columns_base(apop_data *d, char **colnames);
290 
291 #ifdef APOP_NO_VARIADIC
292  apop_data * apop_data_get_page(const apop_data * data, const char * title, const char match) ;
293 #else
294  apop_data * apop_data_get_page_base(const apop_data * data, const char * title, const char match) ;
295  apop_varad_declare(apop_data *, apop_data_get_page, const apop_data * data; const char * title; const char match);
296 #define apop_data_get_page(...) apop_varad_link(apop_data_get_page, __VA_ARGS__)
297 #endif
298 
299 apop_data * apop_data_add_page(apop_data * dataset, apop_data *newpage,const char *title);
300 #ifdef APOP_NO_VARIADIC
301  apop_data* apop_data_rm_page(apop_data * data, const char *title, const char free_p) ;
302 #else
303  apop_data* apop_data_rm_page_base(apop_data * data, const char *title, const char free_p) ;
304  apop_varad_declare(apop_data*, apop_data_rm_page, apop_data * data; const char *title; const char free_p);
305 #define apop_data_rm_page(...) apop_varad_link(apop_data_rm_page, __VA_ARGS__)
306 #endif
307 
308 #ifdef APOP_NO_VARIADIC
309  apop_data * apop_data_rm_rows(apop_data *in, int *drop, int (*do_drop)(apop_data* , void*), void* drop_parameter) ;
310 #else
311  apop_data * apop_data_rm_rows_base(apop_data *in, int *drop, int (*do_drop)(apop_data* , void*), void* drop_parameter) ;
312  apop_varad_declare(apop_data *, apop_data_rm_rows, apop_data *in; int *drop; int (*do_drop)(apop_data* , void*); void* drop_parameter);
313 #define apop_data_rm_rows(...) apop_varad_link(apop_data_rm_rows, __VA_ARGS__)
314 #endif
315 
316 
317 //in apop_asst.c:
318 #ifdef APOP_NO_VARIADIC
319  apop_data * apop_model_draws(apop_model *model, int count, apop_data *draws) ;
320 #else
321  apop_data * apop_model_draws_base(apop_model *model, int count, apop_data *draws) ;
322  apop_varad_declare(apop_data *, apop_model_draws, apop_model *model; int count; apop_data *draws);
323 #define apop_model_draws(...) apop_varad_link(apop_model_draws, __VA_ARGS__)
324 #endif
325 
326 
327 
328 /* Convenience functions to convert among vectors (gsl_vector), matrices (gsl_matrix),
329  arrays (double **), and database tables */
330 
331 //From vector
332 gsl_vector *apop_vector_copy(const gsl_vector *in);
333 #ifdef APOP_NO_VARIADIC
334  gsl_matrix * apop_vector_to_matrix(const gsl_vector *in, char row_col) ;
335 #else
336  gsl_matrix * apop_vector_to_matrix_base(const gsl_vector *in, char row_col) ;
337  apop_varad_declare(gsl_matrix *, apop_vector_to_matrix, const gsl_vector *in; char row_col);
338 #define apop_vector_to_matrix(...) apop_varad_link(apop_vector_to_matrix, __VA_ARGS__)
339 #endif
340 
341 
342 //From matrix
343 gsl_matrix *apop_matrix_copy(const gsl_matrix *in);
344 apop_data *apop_db_to_crosstab(char *tabname, char *r1, char *r2, char *datacol);
345 
346 //From array
347 #ifdef APOP_NO_VARIADIC
348  gsl_vector * apop_array_to_vector(double *in, int size) ;
349 #else
350  gsl_vector * apop_array_to_vector_base(double *in, int size) ;
351  apop_varad_declare(gsl_vector *, apop_array_to_vector, double *in; int size);
352 #define apop_array_to_vector(...) apop_varad_link(apop_array_to_vector, __VA_ARGS__)
353 #endif
354 
355 #define apop_line_to_vector apop_array_to_vector
356 
357 //From text
358 #ifdef APOP_NO_VARIADIC
359  apop_data * apop_text_to_data(char const *text_file, int has_row_names, int has_col_names, int const *field_ends, char const *delimiters) ;
360 #else
361  apop_data * apop_text_to_data_base(char const *text_file, int has_row_names, int has_col_names, int const *field_ends, char const *delimiters) ;
362  apop_varad_declare(apop_data *, apop_text_to_data, char const *text_file; int has_row_names; int has_col_names; int const *field_ends; char const *delimiters);
363 #define apop_text_to_data(...) apop_varad_link(apop_text_to_data, __VA_ARGS__)
364 #endif
365 
366 #ifdef APOP_NO_VARIADIC
367  int apop_text_to_db(char const *text_file, char *tabname, int has_row_names, int has_col_names, char **field_names, int const *field_ends, apop_data *field_params, char *table_params, char const *delimiters, char if_table_exists) ;
368 #else
369  int apop_text_to_db_base(char const *text_file, char *tabname, int has_row_names, int has_col_names, char **field_names, int const *field_ends, apop_data *field_params, char *table_params, char const *delimiters, char if_table_exists) ;
370  apop_varad_declare(int, apop_text_to_db, char const *text_file; char *tabname; int has_row_names; int has_col_names; char **field_names; int const *field_ends; apop_data *field_params; char *table_params; char const *delimiters; char if_table_exists);
371 #define apop_text_to_db(...) apop_varad_link(apop_text_to_db, __VA_ARGS__)
372 #endif
373 
374 
375 //rank data
378 
379 //From crosstabs
380 void apop_crosstab_to_db(apop_data *in, char *tabname, char *row_col_name,
381  char *col_col_name, char *data_col_name);
382 
383 //packing data into a vector
384 #ifdef APOP_NO_VARIADIC
385  gsl_vector * apop_data_pack(const apop_data *in, gsl_vector *out, char all_pages, char use_info_pages) ;
386 #else
387  gsl_vector * apop_data_pack_base(const apop_data *in, gsl_vector *out, char all_pages, char use_info_pages) ;
388  apop_varad_declare(gsl_vector *, apop_data_pack, const apop_data *in; gsl_vector *out; char all_pages; char use_info_pages);
389 #define apop_data_pack(...) apop_varad_link(apop_data_pack, __VA_ARGS__)
390 #endif
391 
392 #ifdef APOP_NO_VARIADIC
393  void apop_data_unpack(const gsl_vector *in, apop_data *d, char use_info_pages) ;
394 #else
395  void apop_data_unpack_base(const gsl_vector *in, apop_data *d, char use_info_pages) ;
396  apop_varad_declare(void, apop_data_unpack, const gsl_vector *in; apop_data *d; char use_info_pages);
397 #define apop_data_unpack(...) apop_varad_link(apop_data_unpack, __VA_ARGS__)
398 #endif
399 
400 
401 #define apop_vector_fill(avfin, ...) apop_vector_fill_base((avfin), (double []) {__VA_ARGS__})
402 #define apop_data_fill(adfin, ...) apop_data_fill_base((adfin), (double []) {__VA_ARGS__})
403 #define apop_text_fill(dataset, ...) apop_text_fill_base((dataset), (char* []) {__VA_ARGS__, NULL})
404 
405 #define apop_data_falloc(sizes, ...) apop_data_fill(apop_data_alloc sizes, __VA_ARGS__)
406 
407 apop_data *apop_data_fill_base(apop_data *in, double []);
408 gsl_vector *apop_vector_fill_base(gsl_vector *in, double []);
409 apop_data *apop_text_fill_base(apop_data *data, char* text[]);
410 
411 int apop_data_set_row(apop_data * row, apop_data *d, int row_number);
412 
413 // Models and model support functions
414 
415 extern apop_model *apop_beta;
416 extern apop_model *apop_bernoulli;
417 extern apop_model *apop_binomial;
418 extern apop_model *apop_chi_squared;
419 extern apop_model *apop_dirichlet;
421 extern apop_model *apop_f_distribution;
422 extern apop_model *apop_gamma;
424 extern apop_model *apop_iv;
426 extern apop_model *apop_loess;
427 extern apop_model *apop_logit;
428 extern apop_model *apop_lognormal;
431 extern apop_model *apop_normal;
432 extern apop_model *apop_ols;
433 extern apop_model *apop_pmf;
434 extern apop_model *apop_poisson;
435 extern apop_model *apop_probit;
437 extern apop_model *apop_uniform;
438 //extern apop_model *apop_wishart;
439 extern apop_model *apop_wls;
440 extern apop_model *apop_yule;
441 extern apop_model *apop_zipf;
442 
443 //model transformations
445 extern apop_model *apop_composition;
447 extern apop_model *apop_mixture;
448 extern apop_model *apop_stack;
449 
452 #define apop_gaussian apop_normal
453 #define apop_OLS apop_ols
454 #define apop_PMF apop_pmf
455 #define apop_F_distribution apop_f_distribution
456 #define apop_WLS apop_wls
457 #define apop_IV apop_iv
458 
459 
460 void apop_model_free (apop_model * free_me);
461 void apop_model_print (apop_model * print_me, FILE *out);
462 void apop_model_show (apop_model * print_me); //deprecated
463 apop_model * apop_model_copy(apop_model *in); //in apop_model.c
465 
467 void apop_score(apop_data *d, gsl_vector *out, apop_model *m);
469 double apop_p(apop_data *d, apop_model *m);
470 double apop_cdf(apop_data *d, apop_model *m);
471 int apop_draw(double *out, gsl_rng *r, apop_model *m);
472 void apop_prep(apop_data *d, apop_model *m);
475 
476 apop_model *apop_beta_from_mean_var(double m, double v); //in apop_beta.c
477 
478 #define apop_model_set_parameters(in, ...) apop_model_set_parameters_base((in), (double []) {__VA_ARGS__})
479 apop_model *apop_model_set_parameters_base(apop_model *in, double ap[]);
480 
481 //apop_mixture.c
485 #define apop_model_mixture(...) apop_model_mixture_base((apop_model *[]){__VA_ARGS__, NULL})
486 apop_model *apop_model_mixture_base(apop_model **inlist);
487 
488 //transform/apop_model_stack.c.
489 apop_model *apop_model_stack_base(apop_model *mlist[]);
490 #define apop_model_stack(...) apop_model_stack_base((apop_model *[]){__VA_ARGS__, NULL})
491 
492  //The variadic versions, with lots of options to input extra parameters to the
493  //function being mapped/applied
494 #ifdef APOP_NO_VARIADIC
495  apop_data * apop_map(apop_data *in, double (*fn_d)(double), double (*fn_v)(gsl_vector*),
496  double (*fn_r)(apop_data *), double (*fn_dp)(double, void *), double (*fn_vp)(gsl_vector*, void *),
497  double (*fn_rp)(apop_data *, void *), double (*fn_dpi)(double, void *, int),
498  double (*fn_vpi)(gsl_vector*, void *, int), double (*fn_rpi)(apop_data*, void *, int),
499  double (*fn_di)(double, int), double (*fn_vi)(gsl_vector*, int), double (*fn_ri)(apop_data*, int),
500  void *param, int inplace, char part, int all_pages) ;
501 #else
502  apop_data * apop_map_base(apop_data *in, double (*fn_d)(double), double (*fn_v)(gsl_vector*),
503  double (*fn_r)(apop_data *), double (*fn_dp)(double, void *), double (*fn_vp)(gsl_vector*, void *),
504  double (*fn_rp)(apop_data *, void *), double (*fn_dpi)(double, void *, int),
505  double (*fn_vpi)(gsl_vector*, void *, int), double (*fn_rpi)(apop_data*, void *, int),
506  double (*fn_di)(double, int), double (*fn_vi)(gsl_vector*, int), double (*fn_ri)(apop_data*, int),
507  void *param, int inplace, char part, int all_pages) ;
508  apop_varad_declare(apop_data *, apop_map, apop_data *in; double (*fn_d)(double); double (*fn_v)(gsl_vector*);
509  double (*fn_r)(apop_data *); double (*fn_dp)(double, void *); double (*fn_vp)(gsl_vector*, void *);
510  double (*fn_rp)(apop_data *, void *); double (*fn_dpi)(double, void *, int);
511  double (*fn_vpi)(gsl_vector*, void *, int); double (*fn_rpi)(apop_data*, void *, int);
512  double (*fn_di)(double, int); double (*fn_vi)(gsl_vector*, int); double (*fn_ri)(apop_data*, int);
513  void *param; int inplace; char part; int all_pages);
514 #define apop_map(...) apop_varad_link(apop_map, __VA_ARGS__)
515 #endif
516 
517 #ifdef APOP_NO_VARIADIC
518  double apop_map_sum(apop_data *in, double (*fn_d)(double), double (*fn_v)(gsl_vector*),
519  double (*fn_r)(apop_data *), double (*fn_dp)(double, void *), double (*fn_vp)(gsl_vector*, void *),
520  double (*fn_rp)(apop_data *, void *), double (*fn_dpi)(double, void *, int),
521  double (*fn_vpi)(gsl_vector*, void *, int), double (*fn_rpi)(apop_data*, void *, int),
522  double (*fn_di)(double, int), double (*fn_vi)(gsl_vector*, int), double (*fn_ri)(apop_data*, int),
523  void *param, char part, int all_pages) ;
524 #else
525  double apop_map_sum_base(apop_data *in, double (*fn_d)(double), double (*fn_v)(gsl_vector*),
526  double (*fn_r)(apop_data *), double (*fn_dp)(double, void *), double (*fn_vp)(gsl_vector*, void *),
527  double (*fn_rp)(apop_data *, void *), double (*fn_dpi)(double, void *, int),
528  double (*fn_vpi)(gsl_vector*, void *, int), double (*fn_rpi)(apop_data*, void *, int),
529  double (*fn_di)(double, int), double (*fn_vi)(gsl_vector*, int), double (*fn_ri)(apop_data*, int),
530  void *param, char part, int all_pages) ;
531  apop_varad_declare(double, apop_map_sum, apop_data *in; double (*fn_d)(double); double (*fn_v)(gsl_vector*);
532  double (*fn_r)(apop_data *); double (*fn_dp)(double, void *); double (*fn_vp)(gsl_vector*, void *);
533  double (*fn_rp)(apop_data *, void *); double (*fn_dpi)(double, void *, int);
534  double (*fn_vpi)(gsl_vector*, void *, int); double (*fn_rpi)(apop_data*, void *, int);
535  double (*fn_di)(double, int); double (*fn_vi)(gsl_vector*, int); double (*fn_ri)(apop_data*, int);
536  void *param; char part; int all_pages);
537 #define apop_map_sum(...) apop_varad_link(apop_map_sum, __VA_ARGS__)
538 #endif
539 
540 
541  //the specific-to-a-type versions, quicker and easier when appropriate.
542 gsl_vector *apop_matrix_map(const gsl_matrix *m, double (*fn)(gsl_vector*));
543 gsl_vector *apop_vector_map(const gsl_vector *v, double (*fn)(double));
544 void apop_matrix_apply(gsl_matrix *m, void (*fn)(gsl_vector*));
545 void apop_vector_apply(gsl_vector *v, void (*fn)(double*));
546 gsl_matrix * apop_matrix_map_all(const gsl_matrix *in, double (*fn)(double));
547 void apop_matrix_apply_all(gsl_matrix *in, void (*fn)(double *));
548 
549 double apop_vector_map_sum(const gsl_vector *in, double(*fn)(double));
550 double apop_matrix_map_sum(const gsl_matrix *in, double (*fn)(gsl_vector*));
551 double apop_matrix_map_all_sum(const gsl_matrix *in, double (*fn)(double));
552 
553 
554  // Some output routines
555 
556 #ifdef APOP_NO_VARIADIC
557  void apop_plot_histogram(gsl_vector *data, size_t bin_count, char *with, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
558 #else
559  void apop_plot_histogram_base(gsl_vector *data, size_t bin_count, char *with, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
560  apop_varad_declare(void, apop_plot_histogram, gsl_vector *data; size_t bin_count; char *with; char const *output_name; FILE *output_pipe; char output_type; char output_append);
561 #define apop_plot_histogram(...) apop_varad_link(apop_plot_histogram, __VA_ARGS__)
562 #endif
563 
564 
565 #ifdef APOP_NO_VARIADIC
566  void apop_matrix_print(const gsl_matrix *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
567 #else
568  void apop_matrix_print_base(const gsl_matrix *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
569  apop_varad_declare(void, apop_matrix_print, const gsl_matrix *data; char const *output_name; FILE *output_pipe; char output_type; char output_append);
570 #define apop_matrix_print(...) apop_varad_link(apop_matrix_print, __VA_ARGS__)
571 #endif
572 
573 #ifdef APOP_NO_VARIADIC
574  void apop_vector_print(gsl_vector *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
575 #else
576  void apop_vector_print_base(gsl_vector *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
577  apop_varad_declare(void, apop_vector_print, gsl_vector *data; char const *output_name; FILE *output_pipe; char output_type; char output_append);
578 #define apop_vector_print(...) apop_varad_link(apop_vector_print, __VA_ARGS__)
579 #endif
580 
581 #ifdef APOP_NO_VARIADIC
582  void apop_data_print(const apop_data *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
583 #else
584  void apop_data_print_base(const apop_data *data, char const *output_name, FILE *output_pipe, char output_type, char output_append) ;
585  apop_varad_declare(void, apop_data_print, const apop_data *data; char const *output_name; FILE *output_pipe; char output_type; char output_append);
586 #define apop_data_print(...) apop_varad_link(apop_data_print, __VA_ARGS__)
587 #endif
588 
589 
590 void apop_matrix_show(const gsl_matrix *data);
591 void apop_vector_show(const gsl_vector *data);
592 void apop_data_show(const apop_data *data);
593 
594 
595  //statistics
596 #ifdef APOP_NO_VARIADIC
597  double apop_vector_mean(gsl_vector const *v, gsl_vector const *weights);
598 #else
599  double apop_vector_mean_base(gsl_vector const *v, gsl_vector const *weights);
600  apop_varad_declare(double, apop_vector_mean, gsl_vector const *v; gsl_vector const *weights);
601 #define apop_vector_mean(...) apop_varad_link(apop_vector_mean, __VA_ARGS__)
602 #endif
603 
604 #ifdef APOP_NO_VARIADIC
605  double apop_vector_var(gsl_vector const *v, gsl_vector const *weights);
606 #else
607  double apop_vector_var_base(gsl_vector const *v, gsl_vector const *weights);
608  apop_varad_declare(double, apop_vector_var, gsl_vector const *v; gsl_vector const *weights);
609 #define apop_vector_var(...) apop_varad_link(apop_vector_var, __VA_ARGS__)
610 #endif
611 
612 #ifdef APOP_NO_VARIADIC
613  double apop_vector_skew_pop(gsl_vector const *v, gsl_vector const *weights);
614 #else
615  double apop_vector_skew_pop_base(gsl_vector const *v, gsl_vector const *weights);
616  apop_varad_declare(double, apop_vector_skew_pop, gsl_vector const *v; gsl_vector const *weights);
617 #define apop_vector_skew_pop(...) apop_varad_link(apop_vector_skew_pop, __VA_ARGS__)
618 #endif
619 
620 #ifdef APOP_NO_VARIADIC
621  double apop_vector_kurtosis_pop(gsl_vector const *v, gsl_vector const *weights);
622 #else
623  double apop_vector_kurtosis_pop_base(gsl_vector const *v, gsl_vector const *weights);
624  apop_varad_declare(double, apop_vector_kurtosis_pop, gsl_vector const *v; gsl_vector const *weights);
625 #define apop_vector_kurtosis_pop(...) apop_varad_link(apop_vector_kurtosis_pop, __VA_ARGS__)
626 #endif
627 
628 #ifdef APOP_NO_VARIADIC
629  double apop_vector_cov(gsl_vector const *v1, gsl_vector const *v2,
630  gsl_vector const *weights);
631 #else
632  double apop_vector_cov_base(gsl_vector const *v1, gsl_vector const *v2,
633  gsl_vector const *weights);
634  apop_varad_declare(double, apop_vector_cov, gsl_vector const *v1; gsl_vector const *v2;
635  gsl_vector const *weights);
636 #define apop_vector_cov(...) apop_varad_link(apop_vector_cov, __VA_ARGS__)
637 #endif
638 
639 
640 #ifdef APOP_NO_VARIADIC
641  double apop_vector_distance(const gsl_vector *ina, const gsl_vector *inb, const char metric, const double norm) ;
642 #else
643  double apop_vector_distance_base(const gsl_vector *ina, const gsl_vector *inb, const char metric, const double norm) ;
644  apop_varad_declare(double, apop_vector_distance, const gsl_vector *ina; const gsl_vector *inb; const char metric; const double norm);
645 #define apop_vector_distance(...) apop_varad_link(apop_vector_distance, __VA_ARGS__)
646 #endif
647 
648 
649 #ifdef APOP_NO_VARIADIC
650  void apop_vector_normalize(gsl_vector *in, gsl_vector **out, const char normalization_type) ;
651 #else
652  void apop_vector_normalize_base(gsl_vector *in, gsl_vector **out, const char normalization_type) ;
653  apop_varad_declare(void, apop_vector_normalize, gsl_vector *in; gsl_vector **out; const char normalization_type);
654 #define apop_vector_normalize(...) apop_varad_link(apop_vector_normalize, __VA_ARGS__)
655 #endif
656 
657 void apop_matrix_normalize(gsl_matrix *data, const char row_or_col, const char normalization);
658 
659 apop_data * apop_data_covariance(const apop_data *in);
660 apop_data * apop_data_correlation(const apop_data *in);
661 long double apop_matrix_sum(const gsl_matrix *m);
662 double apop_matrix_mean(const gsl_matrix *data);
663 void apop_matrix_mean_and_var(const gsl_matrix *data, double *mean, double *var);
664 apop_data * apop_data_summarize(apop_data *data);
665 
666 apop_data *apop_test_fisher_exact(apop_data *intab); //in apop_fisher.c
667 
668 //from apop_t_f_chi.c:
669 #ifdef APOP_NO_VARIADIC
670  int apop_matrix_is_positive_semidefinite(gsl_matrix *m, char semi) ;
671 #else
672  int apop_matrix_is_positive_semidefinite_base(gsl_matrix *m, char semi) ;
673  apop_varad_declare(int, apop_matrix_is_positive_semidefinite, gsl_matrix *m; char semi);
674 #define apop_matrix_is_positive_semidefinite(...) apop_varad_link(apop_matrix_is_positive_semidefinite, __VA_ARGS__)
675 #endif
676 
677 double apop_matrix_to_positive_semidefinite(gsl_matrix *m);
678 long double apop_multivariate_gamma(double a, int p);
679 long double apop_multivariate_lngamma(double a, int p);
680 
681 //apop_tests.c
682 apop_data * apop_t_test(gsl_vector *a, gsl_vector *b);
683 apop_data * apop_paired_t_test(gsl_vector *a, gsl_vector *b);
684 #ifdef APOP_NO_VARIADIC
685  apop_data* apop_anova(char *table, char *data, char *grouping1, char *grouping2) ;
686 #else
687  apop_data* apop_anova_base(char *table, char *data, char *grouping1, char *grouping2) ;
688  apop_varad_declare(apop_data*, apop_anova, char *table; char *data; char *grouping1; char *grouping2);
689 #define apop_anova(...) apop_varad_link(apop_anova, __VA_ARGS__)
690 #endif
691 
692 #define apop_ANOVA apop_anova
693 #ifdef APOP_NO_VARIADIC
694  apop_data * apop_f_test (apop_model *est, apop_data *contrast) ;
695 #else
696  apop_data * apop_f_test_base(apop_model *est, apop_data *contrast) ;
697  apop_varad_declare(apop_data *, apop_f_test, apop_model *est; apop_data *contrast);
698 #define apop_f_test(...) apop_varad_link(apop_f_test, __VA_ARGS__)
699 #endif
700 
701 #define apop_F_test apop_f_test
702 
703 //from the regression code:
704 #define apop_estimate_r_squared(in) apop_estimate_coefficient_of_determination(in)
705 
706 apop_data * apop_text_unique_elements(const apop_data *d, size_t col);
707 gsl_vector * apop_vector_unique_elements(const gsl_vector *v);
708 #ifdef APOP_NO_VARIADIC
709  apop_data * apop_data_to_factors(apop_data *data, char intype, int incol, int outcol) ;
710 #else
711  apop_data * apop_data_to_factors_base(apop_data *data, char intype, int incol, int outcol) ;
712  apop_varad_declare(apop_data *, apop_data_to_factors, apop_data *data; char intype; int incol; int outcol);
713 #define apop_data_to_factors(...) apop_varad_link(apop_data_to_factors, __VA_ARGS__)
714 #endif
715 
716 #ifdef APOP_NO_VARIADIC
717  apop_data * apop_data_get_factor_names(apop_data *data, int col, char type) ;
718 #else
719  apop_data * apop_data_get_factor_names_base(apop_data *data, int col, char type) ;
720  apop_varad_declare(apop_data *, apop_data_get_factor_names, apop_data *data; int col; char type);
721 #define apop_data_get_factor_names(...) apop_varad_link(apop_data_get_factor_names, __VA_ARGS__)
722 #endif
723 
724 
725 #ifdef APOP_NO_VARIADIC
726  apop_data * apop_data_to_dummies(apop_data *d, int col, char type, int keep_first, char append, char remove) ;
727 #else
728  apop_data * apop_data_to_dummies_base(apop_data *d, int col, char type, int keep_first, char append, char remove) ;
729  apop_varad_declare(apop_data *, apop_data_to_dummies, apop_data *d; int col; char type; int keep_first; char append; char remove);
730 #define apop_data_to_dummies(...) apop_varad_link(apop_data_to_dummies, __VA_ARGS__)
731 #endif
732 
733 
734 #ifdef APOP_NO_VARIADIC
735  double apop_kl_divergence(apop_model *from, apop_model *to, int draw_ct, gsl_rng *rng) ;
736 #else
737  double apop_kl_divergence_base(apop_model *from, apop_model *to, int draw_ct, gsl_rng *rng) ;
738  apop_varad_declare(double, apop_kl_divergence, apop_model *from; apop_model *to; int draw_ct; gsl_rng *rng);
739 #define apop_kl_divergence(...) apop_varad_link(apop_kl_divergence, __VA_ARGS__)
740 #endif
741 
742 
745 
746 
747 //Bootstrapping & RNG
748 apop_data * apop_jackknife_cov(apop_data *data, apop_model *model);
749 #ifdef APOP_NO_VARIADIC
750  apop_data * apop_bootstrap_cov(apop_data *data, apop_model *model, gsl_rng* rng, int iterations, char keep_boots, char ignore_nans) ;
751 #else
752  apop_data * apop_bootstrap_cov_base(apop_data *data, apop_model *model, gsl_rng* rng, int iterations, char keep_boots, char ignore_nans) ;
753  apop_varad_declare(apop_data *, apop_bootstrap_cov, apop_data *data; apop_model *model; gsl_rng* rng; int iterations; char keep_boots; char ignore_nans);
754 #define apop_bootstrap_cov(...) apop_varad_link(apop_bootstrap_cov, __VA_ARGS__)
755 #endif
756 
757 gsl_rng *apop_rng_alloc(int seed);
758 double apop_rng_GHgB3(gsl_rng * r, double* a); //in apop_asst.c
759 
760 #define apop_rng_get_thread(thread_in) apop_rng_get_thread_base(#thread_in[0]=='\0' ? -1: (thread_in+0))
761 gsl_rng *apop_rng_get_thread_base(int thread);
762 
763 int apop_arms_draw (double *out, gsl_rng *r, apop_model *m); //apop_arms.h
764 
765 
766  // maximum likelihod estimation related functions
767 
768 #ifdef APOP_NO_VARIADIC
769  gsl_vector * apop_numerical_gradient(apop_data * data, apop_model* model, double delta) ;
770 #else
771  gsl_vector * apop_numerical_gradient_base(apop_data * data, apop_model* model, double delta) ;
772  apop_varad_declare(gsl_vector *, apop_numerical_gradient, apop_data * data; apop_model* model; double delta);
773 #define apop_numerical_gradient(...) apop_varad_link(apop_numerical_gradient, __VA_ARGS__)
774 #endif
775 
776 #ifdef APOP_NO_VARIADIC
777  apop_data * apop_model_hessian(apop_data * data, apop_model *model, double delta) ;
778 #else
779  apop_data * apop_model_hessian_base(apop_data * data, apop_model *model, double delta) ;
780  apop_varad_declare(apop_data *, apop_model_hessian, apop_data * data; apop_model *model; double delta);
781 #define apop_model_hessian(...) apop_varad_link(apop_model_hessian, __VA_ARGS__)
782 #endif
783 
784 #ifdef APOP_NO_VARIADIC
785  apop_data * apop_model_numerical_covariance(apop_data * data, apop_model *model, double delta) ;
786 #else
787  apop_data * apop_model_numerical_covariance_base(apop_data * data, apop_model *model, double delta) ;
788  apop_varad_declare(apop_data *, apop_model_numerical_covariance, apop_data * data; apop_model *model; double delta);
789 #define apop_model_numerical_covariance(...) apop_varad_link(apop_model_numerical_covariance, __VA_ARGS__)
790 #endif
791 
792 
793 void apop_maximum_likelihood(apop_data * data, apop_model *dist);
794 
795 #ifdef APOP_NO_VARIADIC
796  apop_model * apop_estimate_restart (apop_model *e, apop_model *copy, char * starting_pt, double boundary) ;
797 #else
798  apop_model * apop_estimate_restart_base(apop_model *e, apop_model *copy, char * starting_pt, double boundary) ;
799  apop_varad_declare(apop_model *, apop_estimate_restart, apop_model *e; apop_model *copy; char * starting_pt; double boundary);
800 #define apop_estimate_restart(...) apop_varad_link(apop_estimate_restart, __VA_ARGS__)
801 #endif
802 
803 
804 //in apop_linear_constraint.c
805 #ifdef APOP_NO_VARIADIC
806  long double apop_linear_constraint(gsl_vector *beta, apop_data * constraint, double margin) ;
807 #else
808  long double apop_linear_constraint_base(gsl_vector *beta, apop_data * constraint, double margin) ;
809  apop_varad_declare(long double, apop_linear_constraint, gsl_vector *beta; apop_data * constraint; double margin);
810 #define apop_linear_constraint(...) apop_varad_link(apop_linear_constraint, __VA_ARGS__)
811 #endif
812 
813 
814 //in apop_model_fix_params.c
817 
818 
819 
820 
821 
822 
824 
825 /*
826 This declares the vtable macros for each procedure that uses the mechanism.
827 
828 --We want to have type-checking on the functions put into the vtables. Type checking
829 happens only with functions, not macros, so we need a type_check function for every
830 vtable.
831 
832 --Only once in your codebase, you'll need to #define Declare_type_checking_fns to
833 actually define the type checking function. Everywhere else, the function is merely
834 declared.
835 
836 --All other uses point to having a macro, such as using __VA_ARGS__ to allow any sort
837 of inputs to the hash.
838 
839 --We want to have such a macro for every vtable. That means that we need a macro
840 to write macros. We can't do that with C macros. Thus, this file uses m4 macros to
841 generate C macros.
842 
843 --After the m4 definition of make_vtab_fns, each new vtable requires a typedef, a hash
844 definition, and a call to make_vtab_fns to do the rest.
845 */
846 
847 
848 int apop_vtable_add(char const *tabname, void *fn_in, unsigned long hash);
849 void *apop_vtable_get(char const *tabname, unsigned long hash);
850 int apop_vtable_drop(char const *tabname, unsigned long hash);
851 
852 typedef apop_model *(*apop_update_type)(apop_data *, apop_model* , apop_model*);
853 #define apop_update_hash(m1, m2) ( \
854  ((m1)->log_likelihood ? (size_t)(m1)->log_likelihood : \
855  (m1)->p ? (size_t)(m1)->p*33 : \
856  (m1)->draw ? (size_t)(m1)->draw*33*27 \
857  : 33*27*19) \
858  +((m2)->log_likelihood ? (size_t)(m2)->log_likelihood : \
859  (m2)->p ? (size_t)(m2)->p*33 : \
860  (m2)->draw ? (size_t)(m2)->draw*33*27 \
861  : 33*27*19 \
862  ) * 37)
863 #ifdef Declare_type_checking_fns
864 void apop_update_type_check(apop_update_type in){ };
865 #else
866 void apop_update_type_check(apop_update_type in);
867 #endif
868 #define apop_update_vtable_add(fn, ...) apop_update_type_check(fn), apop_vtable_add("apop_update", fn, apop_update_hash(__VA_ARGS__))
869 #define apop_update_vtable_get(...) apop_vtable_get("apop_update", apop_update_hash(__VA_ARGS__))
870 #define apop_update_vtable_drop(...) apop_vtable_drop("apop_update", apop_update_hash(__VA_ARGS__))
871 
872 typedef void (*apop_score_type)(apop_data *d, gsl_vector *gradient, apop_model *params);
873 #define apop_score_hash(m1) ((size_t)((m1)->log_likelihood ? (m1)->log_likelihood : (m1)->p))
874 #ifdef Declare_type_checking_fns
875 void apop_score_type_check(apop_score_type in){ };
876 #else
877 void apop_score_type_check(apop_score_type in);
878 #endif
879 #define apop_score_vtable_add(fn, ...) apop_score_type_check(fn), apop_vtable_add("apop_score", fn, apop_score_hash(__VA_ARGS__))
880 #define apop_score_vtable_get(...) apop_vtable_get("apop_score", apop_score_hash(__VA_ARGS__))
881 #define apop_score_vtable_drop(...) apop_vtable_drop("apop_score", apop_score_hash(__VA_ARGS__))
882 
883 typedef apop_model* (*apop_parameter_model_type)(apop_data *, apop_model *);
884 #define apop_parameter_model_hash(m1) ((size_t)((m1)->log_likelihood ? (m1)->log_likelihood : (m1)->p)*33 + (m1)->estimate ? (size_t)(m1)->estimate: 27)
885 #ifdef Declare_type_checking_fns
886 void apop_parameter_model_type_check(apop_parameter_model_type in){ };
887 #else
888 void apop_parameter_model_type_check(apop_parameter_model_type in);
889 #endif
890 #define apop_parameter_model_vtable_add(fn, ...) apop_parameter_model_type_check(fn), apop_vtable_add("apop_parameter_model", fn, apop_parameter_model_hash(__VA_ARGS__))
891 #define apop_parameter_model_vtable_get(...) apop_vtable_get("apop_parameter_model", apop_parameter_model_hash(__VA_ARGS__))
892 #define apop_parameter_model_vtable_drop(...) apop_vtable_drop("apop_parameter_model", apop_parameter_model_hash(__VA_ARGS__))
893 
894 typedef apop_data * (*apop_predict_type)(apop_data *d, apop_model *params);
895 #define apop_predict_hash(m1) ((size_t)((m1)->log_likelihood ? (m1)->log_likelihood : (m1)->p)*33 + (m1)->estimate ? (size_t)(m1)->estimate: 27)
896 #ifdef Declare_type_checking_fns
897 void apop_predict_type_check(apop_predict_type in){ };
898 #else
899 void apop_predict_type_check(apop_predict_type in);
900 #endif
901 #define apop_predict_vtable_add(fn, ...) apop_predict_type_check(fn), apop_vtable_add("apop_predict", fn, apop_predict_hash(__VA_ARGS__))
902 #define apop_predict_vtable_get(...) apop_vtable_get("apop_predict", apop_predict_hash(__VA_ARGS__))
903 #define apop_predict_vtable_drop(...) apop_vtable_drop("apop_predict", apop_predict_hash(__VA_ARGS__))
904 
905 typedef void (*apop_model_print_type)(apop_model *params, FILE *out);
906 #define apop_model_print_hash(m1) ((m1)->log_likelihood ? (size_t)(m1)->log_likelihood : \
907  (m1)->p ? (size_t)(m1)->p*33 : \
908  (m1)->estimate ? (size_t)(m1)->estimate*33*33 : \
909  (m1)->draw ? (size_t)(m1)->draw*33*27 : \
910  (m1)->cdf ? (size_t)(m1)->cdf*27*27 \
911  : 27)
912 #ifdef Declare_type_checking_fns
913 void apop_model_print_type_check(apop_model_print_type in){ };
914 #else
915 void apop_model_print_type_check(apop_model_print_type in);
916 #endif
917 #define apop_model_print_vtable_add(fn, ...) apop_model_print_type_check(fn), apop_vtable_add("apop_model_print", fn, apop_model_print_hash(__VA_ARGS__))
918 #define apop_model_print_vtable_get(...) apop_vtable_get("apop_model_print", apop_model_print_hash(__VA_ARGS__))
919 #define apop_model_print_vtable_drop(...) apop_vtable_drop("apop_model_print", apop_model_print_hash(__VA_ARGS__))
920 
921 
922 
923 
924 
926 
927 
928 double apop_generalized_harmonic(int N, double s) __attribute__ ((__pure__));
929 
930 apop_data * apop_test_anova_independence(apop_data *d);
931 #define apop_test_ANOVA_independence(d) apop_test_anova_independence(d)
932 
933 #ifdef APOP_NO_VARIADIC
934  int apop_regex(const char *string, const char* regex, apop_data **substrings, const char use_case) ;
935 #else
936  int apop_regex_base(const char *string, const char* regex, apop_data **substrings, const char use_case) ;
937  apop_varad_declare(int, apop_regex, const char *string; const char* regex; apop_data **substrings; const char use_case);
938 #define apop_regex(...) apop_varad_link(apop_regex, __VA_ARGS__)
939 #endif
940 
941 
942 int apop_system(const char *fmt, ...) __attribute__ ((format (printf,1,2)));
943 
944 //Histograms and PMFs
945 gsl_vector * apop_vector_moving_average(gsl_vector *, size_t);
946 apop_data * apop_histograms_test_goodness_of_fit(apop_model *h0, apop_model *h1);
947 apop_data * apop_test_kolmogorov(apop_model *m1, apop_model *m2);
948 apop_data *apop_data_pmf_compress(apop_data *in);
949 #ifdef APOP_NO_VARIADIC
950  apop_data * apop_data_to_bins(apop_data *indata, apop_data *binspec, int bin_count, char close_top_bin) ;
951 #else
952  apop_data * apop_data_to_bins_base(apop_data *indata, apop_data *binspec, int bin_count, char close_top_bin) ;
953  apop_varad_declare(apop_data *, apop_data_to_bins, apop_data *indata; apop_data *binspec; int bin_count; char close_top_bin);
954 #define apop_data_to_bins(...) apop_varad_link(apop_data_to_bins, __VA_ARGS__)
955 #endif
956 
957 #ifdef APOP_NO_VARIADIC
958  apop_model * apop_model_to_pmf(apop_model *model, apop_data *binspec, long int draws, int bin_count, gsl_rng *rng) ;
959 #else
960  apop_model * apop_model_to_pmf_base(apop_model *model, apop_data *binspec, long int draws, int bin_count, gsl_rng *rng) ;
961  apop_varad_declare(apop_model *, apop_model_to_pmf, apop_model *model; apop_data *binspec; long int draws; int bin_count; gsl_rng *rng);
962 #define apop_model_to_pmf(...) apop_varad_link(apop_model_to_pmf, __VA_ARGS__)
963 #endif
964 
965 
966 //text conveniences
967 #ifdef APOP_NO_VARIADIC
968  char* apop_text_paste(apop_data const*strings, char *between, char *before, char *after, char *between_cols, int (*prune)(apop_data* , int , int , void*), void* prune_parameter) ;
969 #else
970  char* apop_text_paste_base(apop_data const*strings, char *between, char *before, char *after, char *between_cols, int (*prune)(apop_data* , int , int , void*), void* prune_parameter) ;
971  apop_varad_declare(char*, apop_text_paste, apop_data const*strings; char *between; char *before; char *after; char *between_cols; int (*prune)(apop_data* , int , int , void*); void* prune_parameter);
972 #define apop_text_paste(...) apop_varad_link(apop_text_paste, __VA_ARGS__)
973 #endif
974 
980 #define Apop_notify(verbosity, ...) {\
981  if (apop_opts.verbose != -1 && apop_opts.verbose >= verbosity) { \
982  if (!apop_opts.log_file) apop_opts.log_file = stderr; \
983  fprintf(apop_opts.log_file, "%s: ", __func__); fprintf(apop_opts.log_file, __VA_ARGS__); fprintf(apop_opts.log_file, "\n"); \
984  fflush(apop_opts.log_file); \
985 } }
986 
987 #define Apop_maybe_abort(level) \
988  {if ((level == -5 && apop_opts.stop_on_warning!='n') \
989  || (apop_opts.verbose >= level && apop_opts.stop_on_warning == 'v') \
990  || (apop_opts.stop_on_warning=='w') ) \
991  raise(SIGTRAP);}
992 
1004 #define Apop_stopif(test, onfail, level, ...) do {\
1005  if (test) { \
1006  Apop_notify(level, __VA_ARGS__); \
1007  Apop_maybe_abort(level) \
1008  onfail; \
1009  } } while(0)
1010 
1011 #define apop_errorlevel -5
1012 
1013 //For use in stopif, to return a blank apop_data set with an error attached.
1014 #define apop_return_data_error(E) {apop_data *out=apop_data_alloc(); out->error='E'; return out;}
1015 
1016 /* The Apop_stopif macro is currently favored, but there's a long history of prior
1017  error-handling setups. Consider all of the Assert... macros below to be deprecated.
1018 */
1019 #define Apop_assert_c(test, returnval, level, ...) \
1020  Apop_stopif(!(test), return returnval, level, __VA_ARGS__)
1021 
1022 #define Apop_assert(test, ...) Apop_assert_c((test), 0, apop_errorlevel, __VA_ARGS__)
1023 
1024 //For things that return void. Transitional and deprecated at birth.
1025 #define Apop_assert_n(test, ...) Apop_assert_c((test), , apop_errorlevel, __VA_ARGS__)
1026 #define Apop_assert_nan(test, ...) Apop_assert_c((test), GSL_NAN, apop_errorlevel, __VA_ARGS__)
1027 #define Apop_assert_negone(test, ...) Apop_assert_c((test), -1, apop_errorlevel, __VA_ARGS__)
1028 
1029 //Missing data
1030 #ifdef APOP_NO_VARIADIC
1031  apop_data * apop_data_listwise_delete(apop_data *d, char inplace) ;
1032 #else
1033  apop_data * apop_data_listwise_delete_base(apop_data *d, char inplace) ;
1034  apop_varad_declare(apop_data *, apop_data_listwise_delete, apop_data *d; char inplace);
1035 #define apop_data_listwise_delete(...) apop_varad_link(apop_data_listwise_delete, __VA_ARGS__)
1036 #endif
1037 
1038 apop_model * apop_ml_impute(apop_data *d, apop_model* meanvar);
1039 #define apop_ml_imputation(d, m) apop_ml_impute(d, m)
1040 
1041 #ifdef APOP_NO_VARIADIC
1042  apop_model *apop_model_metropolis(apop_data *d, gsl_rng* rng, apop_model *m);
1043 #else
1044  apop_model * apop_model_metropolis_base(apop_data *d, gsl_rng* rng, apop_model *m);
1045  apop_varad_declare(apop_model *, apop_model_metropolis, apop_data *d; gsl_rng* rng; apop_model *m);
1046 #define apop_model_metropolis(...) apop_varad_link(apop_model_metropolis, __VA_ARGS__)
1047 #endif
1048 
1049 #ifdef APOP_NO_VARIADIC
1050  apop_model * apop_update(apop_data *data, apop_model *prior, apop_model *likelihood, gsl_rng *rng) ;
1051 #else
1052  apop_model * apop_update_base(apop_data *data, apop_model *prior, apop_model *likelihood, gsl_rng *rng) ;
1053  apop_varad_declare(apop_model *, apop_update, apop_data *data; apop_model *prior; apop_model *likelihood; gsl_rng *rng);
1054 #define apop_update(...) apop_varad_link(apop_update, __VA_ARGS__)
1055 #endif
1056 
1057 
1058 #ifdef APOP_NO_VARIADIC
1059  double apop_test(double statistic, char *distribution, double p1, double p2, char tail) ;
1060 #else
1061  double apop_test_base(double statistic, char *distribution, double p1, double p2, char tail) ;
1062  apop_varad_declare(double, apop_test, double statistic; char *distribution; double p1; double p2; char tail);
1063 #define apop_test(...) apop_varad_link(apop_test, __VA_ARGS__)
1064 #endif
1065 
1066 
1067 //Sorting (apop_asst.c)
1068 #ifdef APOP_NO_VARIADIC
1069  double * apop_vector_percentiles(gsl_vector *data, char rounding) ;
1070 #else
1071  double * apop_vector_percentiles_base(gsl_vector *data, char rounding) ;
1072  apop_varad_declare(double *, apop_vector_percentiles, gsl_vector *data; char rounding);
1073 #define apop_vector_percentiles(...) apop_varad_link(apop_vector_percentiles, __VA_ARGS__)
1074 #endif
1075 
1076 
1077 //apop_sort.c
1078 #ifdef APOP_NO_VARIADIC
1079  apop_data *apop_data_sort(apop_data *data, apop_data *sort_order, char asc, char inplace, double *col_order);
1080 #else
1081  apop_data * apop_data_sort_base(apop_data *data, apop_data *sort_order, char asc, char inplace, double *col_order);
1082  apop_varad_declare(apop_data *, apop_data_sort, apop_data *data; apop_data *sort_order; char asc; char inplace; double *col_order);
1083 #define apop_data_sort(...) apop_varad_link(apop_data_sort, __VA_ARGS__)
1084 #endif
1085 
1086 
1087 //raking
1088 #ifdef APOP_NO_VARIADIC
1089  apop_data * apop_rake(char const *margin_table, char * const*var_list,
1090  int var_ct, char const *all_vars, char * const *contrasts, int contrast_ct,
1091  char const *structural_zeros, int max_iterations, double tolerance,
1092  char const *count_col, int run_number, char const *init_table,
1093  char const *init_count_col, double nudge, char const* table_name) ;
1094 #else
1095  apop_data * apop_rake_base(char const *margin_table, char * const*var_list,
1096  int var_ct, char const *all_vars, char * const *contrasts, int contrast_ct,
1097  char const *structural_zeros, int max_iterations, double tolerance,
1098  char const *count_col, int run_number, char const *init_table,
1099  char const *init_count_col, double nudge, char const* table_name) ;
1100  apop_varad_declare(apop_data *, apop_rake, char const *margin_table; char * const*var_list;
1101  int var_ct; char const *all_vars; char * const *contrasts; int contrast_ct;
1102  char const *structural_zeros; int max_iterations; double tolerance;
1103  char const *count_col; int run_number; char const *init_table;
1104  char const *init_count_col; double nudge; char const* table_name);
1105 #define apop_rake(...) apop_varad_link(apop_rake, __VA_ARGS__)
1106 #endif
1107 
1108 
1109 
1110 #include <gsl/gsl_cdf.h>
1111 #include <gsl/gsl_blas.h>
1112 #include <gsl/gsl_sf_log.h>
1113 #include <gsl/gsl_sf_exp.h>
1114 #include <gsl/gsl_linalg.h>
1115 #include <gsl/gsl_sf_gamma.h>
1116 #include <gsl/gsl_sf_psi.h>
1117 #include <gsl/gsl_randist.h>
1118 #include <gsl/gsl_histogram.h>
1119 #include <gsl/gsl_statistics_double.h>
1120 
1121 
1122  //First, some linear algebra utilities
1123 
1124 double apop_det_and_inv(const gsl_matrix *in, gsl_matrix **out, int calc_det, int calc_inv);
1125 #ifdef APOP_NO_VARIADIC
1126  apop_data * apop_dot(const apop_data *d1, const apop_data *d2, char form1, char form2) ;
1127 #else
1128  apop_data * apop_dot_base(const apop_data *d1, const apop_data *d2, char form1, char form2) ;
1129  apop_varad_declare(apop_data *, apop_dot, const apop_data *d1; const apop_data *d2; char form1; char form2);
1130 #define apop_dot(...) apop_varad_link(apop_dot, __VA_ARGS__)
1131 #endif
1132 
1133 #ifdef APOP_NO_VARIADIC
1134  int apop_vector_bounded(const gsl_vector *in, long double max) ;
1135 #else
1136  int apop_vector_bounded_base(const gsl_vector *in, long double max) ;
1137  apop_varad_declare(int, apop_vector_bounded, const gsl_vector *in; long double max);
1138 #define apop_vector_bounded(...) apop_varad_link(apop_vector_bounded, __VA_ARGS__)
1139 #endif
1140 
1141 gsl_matrix * apop_matrix_inverse(const gsl_matrix *in) ;
1142 double apop_matrix_determinant(const gsl_matrix *in) ;
1143 //apop_data* apop_sv_decomposition(gsl_matrix *data, int dimensions_we_want);
1144 #ifdef APOP_NO_VARIADIC
1145  apop_data * apop_matrix_pca(gsl_matrix *data, int const dimensions_we_want) ;
1146 #else
1147  apop_data * apop_matrix_pca_base(gsl_matrix *data, int const dimensions_we_want) ;
1148  apop_varad_declare(apop_data *, apop_matrix_pca, gsl_matrix *data; int const dimensions_we_want);
1149 #define apop_matrix_pca(...) apop_varad_link(apop_matrix_pca, __VA_ARGS__)
1150 #endif
1151 
1152 #ifdef APOP_NO_VARIADIC
1153  gsl_vector * apop_vector_stack(gsl_vector *v1, gsl_vector * v2, char inplace) ;
1154 #else
1155  gsl_vector * apop_vector_stack_base(gsl_vector *v1, gsl_vector * v2, char inplace) ;
1156  apop_varad_declare(gsl_vector *, apop_vector_stack, gsl_vector *v1; gsl_vector * v2; char inplace);
1157 #define apop_vector_stack(...) apop_varad_link(apop_vector_stack, __VA_ARGS__)
1158 #endif
1159 
1160 #ifdef APOP_NO_VARIADIC
1161  gsl_matrix * apop_matrix_stack(gsl_matrix *m1, gsl_matrix * m2, char posn, char inplace) ;
1162 #else
1163  gsl_matrix * apop_matrix_stack_base(gsl_matrix *m1, gsl_matrix * m2, char posn, char inplace) ;
1164  apop_varad_declare(gsl_matrix *, apop_matrix_stack, gsl_matrix *m1; gsl_matrix * m2; char posn; char inplace);
1165 #define apop_matrix_stack(...) apop_varad_link(apop_matrix_stack, __VA_ARGS__)
1166 #endif
1167 
1168 gsl_matrix * apop_matrix_rm_columns(gsl_matrix *in, int *drop);
1169 
1170 void apop_vector_log(gsl_vector *v);
1171 void apop_vector_log10(gsl_vector *v);
1172 void apop_vector_exp(gsl_vector *v);
1173 
1175 #define APOP_SUBMATRIX(m, srow, scol, nrows, ncols, o) gsl_matrix apop_mm_##o = gsl_matrix_submatrix((m), (srow), (scol), (nrows),(ncols)).matrix;\
1176 gsl_matrix * o = &( apop_mm_##o );
1177 
1179 #define Apop_row_v(m, row, v) Apop_matrix_row((m)->matrix, row, v)
1180 
1182 #define Apop_col_v(m, col, v) gsl_vector apop_vv_##v = ((col) == -1) ? (gsl_vector){} : gsl_matrix_column((m)->matrix, (col)).vector;\
1183 gsl_vector * v = ((col)==-1) ? (m)->vector : &( apop_vv_##v );
1184 
1186 #define Apop_rows(d, rownum, len, outd) apop_data *outd = Apop_rs(d, rownum, len)
1187 
1189 #define Apop_row(d, row, outd) Apop_rows(d, row, 1, outd)
1190 
1192 #define Apop_cols(d, colnum, len, outd) apop_data *outd = Apop_cs(d, colnum, len);
1193 
1194 #define Apop_row_tv(m, row, v) gsl_vector apop_vv_##v = gsl_matrix_row((m)->matrix, apop_name_find((m)->names, row, 'r')).vector;\
1195 gsl_vector * v = &( apop_vv_##v );
1196 
1197 #define Apop_col_tv(m, col, v) gsl_vector apop_vv_##v = gsl_matrix_column((m)->matrix, apop_name_find((m)->names, col, 'c')).vector;\
1198 gsl_vector * v = &( apop_vv_##v );
1199 
1200 #define Apop_row_t(d, rowname, outd) int apop_row_##outd = apop_name_find((d)->names, rowname, 'r'); Apop_rows(d, apop_row_##outd, 1, outd)
1201 
1202 #define Apop_col_t(d, colname, outd) int apop_col_##outd = apop_name_find((d)->names, colname, 'c'); Apop_cols(d, apop_col_##outd, 1, outd)
1203 
1204 // The above versions relied on gsl_views, which stick to C as of 1989 CE.
1205 // Better to just create the views via designated initializers.
1206 
1207 #define Apop_subm(data_to_view, srow, scol, nrows, ncols)( \
1208  (!(data_to_view) \
1209  || (data_to_view)->size1 < (srow)+(nrows) || (srow) < 0 \
1210  || (data_to_view)->size2 < (scol)+(ncols) || (scol) < 0) ? NULL \
1211  : &(gsl_matrix){.size1=(nrows), .size2=(ncols), \
1212  .tda=(data_to_view)->tda, \
1213  .data=gsl_matrix_ptr((data_to_view), (srow), (scol))} \
1214  )
1215 
1216 #define Apop_rv(data_to_view, row) ( \
1217  ((data_to_view) == NULL || (data_to_view)->matrix == NULL \
1218  || (data_to_view)->matrix->size1 <= (row) || (row) < 0) ? NULL \
1219  : &(gsl_vector){.size=(data_to_view)->matrix->size2, \
1220  .stride=1, .data=gsl_matrix_ptr((data_to_view)->matrix, (row), 0)} \
1221  )
1222 
1223 #define Apop_cv(data_to_view, col) ( \
1224  !(data_to_view) ? NULL \
1225  : (col)==-1 ? (data_to_view)->vector \
1226  : (!(data_to_view)->matrix \
1227  || (data_to_view)->matrix->size2 <= (col) || ((int)(col)) < -1) ? NULL \
1228  : &(gsl_vector){.size=(data_to_view)->matrix->size1, \
1229  .stride=(data_to_view)->matrix->tda, .data=gsl_matrix_ptr((data_to_view)->matrix, 0, (col))} \
1230  )
1231 
1232 /* Not (yet) for public use. \hideinitializer */
1233 #define apop_subvector(v, start, len) ( \
1234  ((v) == NULL || (v)->size < ((start)+(len)) || (start) < 0) ? NULL \
1235  : &(gsl_vector){.size=(len), .stride=(v)->stride, .data=(v)->data+(start*(v)->stride)})
1236 
1237 /* Not (yet) for public use. \hideinitializer */
1238 #define apop_mrow(m, row) ( \
1239  ((m) == NULL || (m)->size1 <= (row) || (row) < 0) ? NULL \
1240  : &(gsl_matrix){.size1=1, .size2=(m)->size2, \
1241  .tda=(m)->tda, .data=gsl_matrix_ptr((m), (row), 0)} \
1242  )
1243 
1244 #define Apop_rs(d, rownum, len)( \
1245  (!(d) || (rownum) < 0) ? NULL \
1246  : &(apop_data){ \
1247  .names= ( !((d)->names) ? NULL : \
1248  &(apop_name){ \
1249  .title = (d)->names->title, \
1250  .vector = (d)->names->vector, \
1251  .col = (d)->names->col, \
1252  .row = ((d)->names->row && (d)->names->rowct > (rownum)) ? &((d)->names->row[rownum]) : NULL, \
1253  .text = (d)->names->text, \
1254  .colct = (d)->names->colct, \
1255  .rowct = (d)->names->row ? (GSL_MIN(1, GSL_MAX((d)->names->rowct - (int)(rownum), 0))) \
1256  : 0, \
1257  .textct = (d)->names->textct }), \
1258  .vector= apop_subvector((d->vector), (rownum), (len)), \
1259  .matrix = Apop_subm(((d)->matrix), (rownum), 0, (len), (d)->matrix?(d)->matrix->size2:0), \
1260  .weights = apop_subvector(((d)->weights), (rownum), (len)), \
1261  .textsize[0]=(d)->textsize[0]> (rownum)+(len)-1 ? (len) : 0, \
1262  .textsize[1]=(d)->textsize[1], \
1263  .text = (d)->text ? &((d)->text[rownum]) : NULL, \
1264  })
1265 
1266 #define Apop_cs(d, colnum, len) ( \
1267  (!(d)||!(d)->matrix || (d)->matrix->size2 <= (colnum)+(len)-1 \
1268  ? NULL \
1269  : &(apop_data){ \
1270  .vector= NULL, \
1271  .weights= (d)->weights, \
1272  .matrix = Apop_subm((d)->matrix, 0, colnum, (d)->matrix->size1, (len)),\
1273  .textsize[0] = 0, \
1274  .textsize[1] = 0, \
1275  .text = NULL, \
1276  .names= (d)->names ? &(apop_name){ \
1277  .title = (d)->names->title, \
1278  .vector = NULL, \
1279  .row = (d)->names->row, \
1280  .col = ((d)->names->col && (d)->names->colct > colnum) ? &((d)->names->col[colnum]) : NULL, \
1281  .text = NULL, \
1282  .rowct = (d)->names->rowct, \
1283  .colct = (d)->names->col ? (GSL_MIN(len, GSL_MAX((d)->names->colct - colnum, 0))) \
1284  : 0, \
1285  .textct = (d)->names->textct } : NULL \
1286  })
1287 
1288 #define Apop_r(d, rownum) Apop_rs(d, rownum, 1)
1289 #define Apop_c(d, col) Apop_cs(d, col, 1)
1290 
1291 #define APOP_COL Apop_col
1292 #define apop_col Apop_col
1293 #define APOP_COLS Apop_cols
1294 #define apop_cols Apop_cols
1295 #define APOP_COL_T Apop_col_t
1296 #define apop_col_t Apop_col_t
1297 #define APOP_COL_TV Apop_col_tv
1298 #define apop_col_tv Apop_col_tv
1299 #define APOP_COL_V Apop_col_v
1300 #define apop_col_v Apop_col_v
1301 
1302 #define APOP_ROW Apop_row
1303 #define apop_row Apop_row
1304 #define Apop_data_row Apop_row #deprecated
1305 #define APOP_ROWS Apop_rows
1306 #define apop_rows Apop_rows
1307 #define APOP_ROW_T Apop_row_t
1308 #define apop_row_t Apop_row_t
1309 #define APOP_ROW_TV Apop_row_tv
1310 #define apop_row_tv Apop_row_tv
1311 #define APOP_ROW_V Apop_row_v
1312 #define apop_row_v Apop_row_v
1313 
1331 #define Apop_matrix_row(m, row, v) gsl_vector apop_vv_##v = gsl_matrix_row((m), (row)).vector;\
1332 gsl_vector * v = &( apop_vv_##v );
1333 
1351 #define Apop_matrix_col(m, col, v) gsl_vector apop_vv_##v = gsl_matrix_column((m), (col)).vector;\
1352 gsl_vector * v = &( apop_vv_##v );
1353 
1354 #define Apop_submatrix APOP_SUBMATRIX
1355 #define APOP_MATRIX_ROW Apop_matrix_row
1356 #define apop_matrix_row Apop_matrix_row
1357 #define APOP_MATRIX_COL Apop_matrix_col
1358 #define apop_matrix_col Apop_matrix_col
1359 
1360 
1361 long double apop_vector_sum(const gsl_vector *in);
1362 double apop_vector_var_m(const gsl_vector *in, const double mean);
1363 double apop_vector_correlation(const gsl_vector *ina, const gsl_vector *inb);
1364 double apop_vector_kurtosis(const gsl_vector *in);
1365 double apop_vector_skew(const gsl_vector *in);
1366 
1367 #define apop_sum(in) apop_vector_sum(in)
1368 #define apop_var(in) apop_vector_var(in)
1369 #define apop_mean(in) apop_vector_mean(in)
1370 
1484 
1486 #ifdef APOP_NO_VARIADIC
1487  int apop_table_exists(char const *name, char remove) ;
1488 #else
1489  int apop_table_exists_base(char const *name, char remove) ;
1490  apop_varad_declare(int, apop_table_exists, char const *name; char remove);
1491 #define apop_table_exists(...) apop_varad_link(apop_table_exists, __VA_ARGS__)
1492 #endif
1493 
1494 
1495 int apop_db_open(char const *filename);
1496 #ifdef APOP_NO_VARIADIC
1497  int apop_db_close(char vacuum) ;
1498 #else
1499  int apop_db_close_base(char vacuum) ;
1500  apop_varad_declare(int, apop_db_close, char vacuum);
1501 #define apop_db_close(...) apop_varad_link(apop_db_close, __VA_ARGS__)
1502 #endif
1503 
1504 
1505 int apop_query(const char *q, ...) __attribute__ ((format (printf,1,2)));
1506 gsl_matrix * apop_query_to_matrix(const char * fmt, ...) __attribute__ ((format (printf,1,2)));
1507 apop_data * apop_query_to_text(const char * fmt, ...) __attribute__ ((format (printf,1,2)));
1508 apop_data * apop_query_to_data(const char * fmt, ...) __attribute__ ((format (printf,1,2)));
1509 apop_data * apop_query_to_mixed_data(const char *typelist, const char * fmt, ...) __attribute__ ((format (printf,2,3)));
1510 gsl_vector * apop_query_to_vector(const char * fmt, ...) __attribute__ ((format (printf,1,2)));
1511 double apop_query_to_float(const char * fmt, ...) __attribute__ ((format (printf,1,2)));
1512 
1513 int apop_data_to_db(const apop_data *set, const char *tabname, char);
1514 
1515 
1517 
1518  //Part I: macros and fns for getting/setting settings groups and elements
1519 
1520 void * apop_settings_get_grp(apop_model *m, char *type, char fail);
1521 void apop_settings_remove_group(apop_model *m, char *delme);
1522 void apop_settings_copy_group(apop_model *outm, apop_model *inm, char *copyme);
1523 void *apop_settings_group_alloc(apop_model *model, char *type, void *free_fn, void *copy_fn, void *the_group);
1524 apop_model *apop_settings_group_alloc_wm(apop_model *model, char *type, void *free_fn, void *copy_fn, void *the_group);
1525 
1535 #define Apop_settings_get_group(m, type) apop_settings_get_grp(m, #type, 'c')
1536 
1542 #define Apop_settings_rm_group(m, type) apop_settings_remove_group(m, #type)
1543 
1556 #define Apop_settings_add_group(model, type, ...) \
1557  apop_settings_group_alloc(model, #type, type ## _settings_free, type ## _settings_copy, type ##_settings_init ((type ## _settings) {__VA_ARGS__}))
1558 
1564 #define apop_model_copy_set(model, type, ...) \
1565  apop_settings_group_alloc_wm(apop_model_copy(model), #type, type ## _settings_free, type ## _settings_copy, type ##_settings_init ((type ## _settings) {__VA_ARGS__}))
1566 
1570 #define Apop_settings_get(model, type, setting) \
1571  (((type ## _settings *) apop_settings_get_grp(model, #type, 'f'))->setting)
1572 
1579 #define Apop_settings_set(model, type, setting, data) \
1580  do { \
1581  if (!(model)) continue; /* silent fail. */ \
1582  type ## _settings *apop_tmp_settings = apop_settings_get_grp(model, #type, 'c'); \
1583  Apop_stopif(!apop_tmp_settings, (model)->error='s', 0, "You're trying to modify a setting in " \
1584  #model "'s setting group of type " #type " but that model doesn't have such a group."); \
1585  apop_tmp_settings->setting = (data); \
1586  } while (0);
1587 
1589 #define Apop_settings_add Apop_settings_set
1590 #define APOP_SETTINGS_ADD Apop_settings_set
1591 #define apop_settings_set Apop_settings_set
1592 #define APOP_SETTINGS_GET Apop_settings_get
1593 #define apop_settings_get Apop_settings_get
1594 #define APOP_SETTINGS_ADD_GROUP Apop_settings_add_group
1595 #define apop_settings_add_group Apop_settings_add_group
1596 #define APOP_SETTINGS_GET_GROUP Apop_settings_get_group
1597 #define apop_settings_get_group Apop_settings_get_group
1598 #define APOP_SETTINGS_RM_GROUP Apop_settings_rm_group
1599 #define apop_settings_rm_group Apop_settings_rm_group
1600 #define Apop_model_copy_set apop_model_copy_set
1601 
1602 //deprecated:
1603 #define Apop_model_add_group Apop_settings_add_group
1604  //End of Doxygen ignore.
1606 
1607 #define Apop_settings_declarations(ysg) \
1608  ysg##_settings * ysg##_settings_init(ysg##_settings); \
1609  void * ysg##_settings_copy(ysg##_settings *); \
1610  void ysg##_settings_free(ysg##_settings *);
1611 
1626 #define Apop_settings_init(name, ...) \
1627  name##_settings *name##_settings_init(name##_settings in) { \
1628  name##_settings *out = malloc(sizeof(name##_settings)); \
1629  *out = in; \
1630  __VA_ARGS__; \
1631  return out; \
1632  }
1633 
1634 #define Apop_varad_set(var, value) (out)->var = (in).var ? (in).var : (value);
1635 
1655 #define Apop_settings_copy(name, ...) \
1656  void * name##_settings_copy(name##_settings *in) {\
1657  name##_settings *out = malloc(sizeof(name##_settings)); \
1658  *out = *in; \
1659  __VA_ARGS__; \
1660  return out; \
1661  }
1662 
1680 #define Apop_settings_free(name, ...) \
1681  void name##_settings_free(name##_settings *in) {\
1682  __VA_ARGS__; \
1683  free(in); \
1684  }
1685 
1686  //Part II: the details of extant settings groups.
1687 
1688 
1691 typedef struct{
1692  double *starting_pt;
1695  char *method;
1718  double step_size,
1719  tolerance,
1720 delta;
1723  int verbose;
1732 //simulated annealing (also uses step_size);
1733  int n_tries, iters_fixed_T;
1734  double k, t_initial, mu_t, t_min ;
1735  gsl_rng *rng;
1736  apop_data **path;
1749 
1752 typedef struct {
1754  apop_data *instruments;
1755  char want_cov;
1757  apop_model *input_distribution;
1759 
1784 typedef struct {
1785  //init/copy/free are in apop_mle.c
1786  char covariance; /*< If 'y', calculate the covariance matrix. Default 'n'. */
1787  char predicted;/*< If 'y', calculate the predicted values. This is typically as many
1788  items as rows in your data set. Default 'n'. */
1789  char tests;/*< If 'y', run any hypothesis tests offered by the model's estimation routine. Default 'n'. */
1790  char info;/*< If 'y', add an info table with elements such as log likelihood or AIC. Default 'n'. */
1792 
1795 typedef struct {
1796  int draws;
1797  gsl_rng *rng;
1798  apop_model *cdf_model;
1799  gsl_matrix *draws_made;
1802 
1803 
1806 typedef struct {
1807  apop_model *base;
1808  int index;
1809  gsl_rng *rng;
1810  int draws;
1812 
1813 
1815 typedef struct {
1816  gsl_vector *cmf;
1817  char draw_index;
1819  long double total_weight;
1820  int *cmf_refct;
1822 
1823 
1827 typedef struct{
1828  apop_data *base_data;
1829  apop_model *base_pmf;
1831  apop_model *kernel;
1833  void (*set_fn)(apop_data*, apop_model*);
1835  int own_pmf, own_kernel;
1837 
1838 struct apop_mcmc_settings;
1839 
1855 typedef struct apop_mcmc_proposal_s {
1856  apop_model *proposal;
1863  void (*step_fn)(double const *, struct apop_mcmc_proposal_s*, struct apop_mcmc_settings *);
1871  int (*adapt_fn)(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms);
1878 
1882 typedef struct apop_mcmc_settings {
1883  apop_data *data;
1884  long int periods;
1885  double burnin;
1888  double last_ll;
1889  apop_model *pmf;
1891  apop_model *base_model;
1912  size_t *block_starts;
1913  int block_count, proposal_is_cp;
1915  char start_at;
1920  void (*base_step_fn)(double const *, struct apop_mcmc_proposal_s*, struct apop_mcmc_settings *);
1921  int (*base_adapt_fn)(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms);
1924 
1925 //Loess, including the old FORTRAN-to-C.
1927  struct {
1928  long n, p;
1929  double *y, *x;
1930  double *weights;
1931  } in;
1932  struct {
1933  double span;
1934  long degree;
1935  long normalize;
1936  long parametric[8];
1937  long drop_square[8];
1938  char *family;
1939  } model;
1940  struct {
1941  char *surface;
1942  char *statistics;
1943  double cell;
1944  char *trace_hat;
1945  long iterations;
1946  } control;
1947  struct {
1948  long *parameter, *a;
1949  double *xi, *vert, *vval;
1950  } kd_tree;
1951  struct {
1952  double *fitted_values;
1953  double *fitted_residuals;
1954  double enp, s;
1955  double one_delta, two_delta;
1956  double *pseudovalues;
1957  double trace_hat;
1958  double *diagonal;
1959  double *robust;
1960  double *divisor;
1961  } out;
1962 };
1963 
2064 typedef struct {
2065  apop_data *data;
2066  struct loess_struct lo_s;
2069  double ci_level;
2072 
2073 
2075 typedef struct point { /* a point in the x,y plane */
2076  double x,y; /* x and y coordinates */
2077  double ey; /* exp(y-ymax+YCEIL) */
2078  double cum; /* integral up to x of rejection envelope */
2079  int f; /* is y an evaluated point of log-density */
2080  struct point *pl,*pr; /* envelope points to left and right of x */
2081 } POINT;
2082 
2083 /* This includes the envelope info and the metropolis steps. */
2084 typedef struct { /* attributes of the entire rejection envelope */
2085  int cpoint; /* number of POINTs in current envelope */
2086  int npoint; /* max number of POINTs allowed in envelope */
2087  double ymax; /* the maximum y-value in the current envelope */
2088  POINT *p; /* start of storage of envelope POINTs */
2089  double *convex; /* adjustment for convexity */
2090  double metro_xprev; /* previous Markov chain iterate */
2091  double metro_yprev; /* current log density at xprev */
2092 } arms_state;
2096 typedef struct {
2097  double *xinit;
2098  double xl;
2099  double xr;
2100  double convex;
2101  int ninit;
2102  int npoint;
2103  char do_metro;
2104  double xprev;
2105  int neval;
2106  arms_state *state;
2107  apop_model *model;
2109 
2110 
2111 typedef struct {
2112  char *splitpage;
2113  apop_model *model1;
2114  apop_model *model2;
2116 
2117 typedef struct {
2118  apop_data *(*base_to_transformed)(apop_data*);
2119  apop_data *(*transformed_to_base)(apop_data*);
2120  double (*jacobian_to_base)(apop_data*);
2121  apop_model *base_model;
2126 typedef struct {
2127  apop_model *base_model;
2128  double (*constraint)(apop_data *, apop_model *);
2129  double (*scaling)(apop_model *);
2130  gsl_rng *rng;
2132  int draw_ct;
2134 
2135 typedef struct {
2136  apop_model *generator_m;
2137  apop_model *ll_m;
2138  int draw_ct;
2145 typedef struct {
2146  gsl_vector *weights;
2147  apop_model **model_list;
2148  int model_count;
2150  apop_model *cmf;
2151  int *cmf_refct;
2153 
2154  //Models built via call to apop_model_copy_set.
2155 
2156 #define apop_model_coordinate_transform(...) Apop_model_copy_set(apop_coordinate_transform, apop_ct, __VA_ARGS__)
2157 #define apop_model_dcompose(...) Apop_model_copy_set(apop_composition, apop_composition, __VA_ARGS__)
2158 #define apop_model_dconstrain(...) Apop_model_copy_set(apop_dconstrain, apop_dconstrain, __VA_ARGS__)
2159 
2162 //Doxygen drops whatever is after these declarations, so I put them last.
2163 Apop_settings_declarations(apop_ct)
2164 Apop_settings_declarations(apop_lm)
2165 Apop_settings_declarations(apop_pm)
2166 Apop_settings_declarations(apop_pmf)
2167 Apop_settings_declarations(apop_mle)
2168 Apop_settings_declarations(apop_cdf)
2169 Apop_settings_declarations(apop_arms)
2170 Apop_settings_declarations(apop_mcmc)
2171 Apop_settings_declarations(apop_loess)
2172 Apop_settings_declarations(apop_stack)
2173 Apop_settings_declarations(apop_mixture)
2174 Apop_settings_declarations(apop_dconstrain)
2175 Apop_settings_declarations(apop_composition)
2176 Apop_settings_declarations(apop_parts_wanted)
2177 Apop_settings_declarations(apop_kernel_density)
2178 
2179 #ifdef __cplusplus
2180 }
2181 #endif
2182 
2183 //Part of the intent of a convenience header like this is that you
2184 //don't have to remember what else you're including. So here are
2185 //some other common GSL headers:
2186 #include <math.h>
2187 #include <gsl/gsl_sort.h>
2188 #include <gsl/gsl_eigen.h>
2189 #include <gsl/gsl_sort_vector.h>
2190 #include <gsl/gsl_permutation.h>
2191 #include <gsl/gsl_integration.h>
apop_data * instruments
Definition: apop.h:1754
apop_data * apop_paired_t_test(gsl_vector *a, gsl_vector *b)
Definition: apop_tests.c:82
double apop_matrix_map_all_sum(const gsl_matrix *in, double(*fn)(double))
Definition: apop_mapply.c:445
void apop_settings_copy_group(apop_model *outm, apop_model *inm, char *copyme)
Definition: apop_settings.c:90
apop_data * apop_t_test(gsl_vector *a, gsl_vector *b)
Definition: apop_tests.c:47
void(* base_step_fn)(double const *, struct apop_mcmc_proposal_s *, struct apop_mcmc_settings *)
Definition: apop.h:1920
Definition: apop.h:77
double target_accept_rate
Definition: apop.h:1898
struct apop_data apop_data
apop_model * apop_model_clear(apop_data *data, apop_model *model)
Definition: apop_model.c:24
apop_model * apop_model_metropolis(apop_data *d, gsl_rng *rng, apop_model *m)
Definition: apop_mcmc.c:291
gsl_vector * weights
Definition: apop.h:2146
double * xinit
Definition: apop.h:2097
void apop_data_unpack(const gsl_vector *in, apop_data *d, char use_info_pages)
Definition: apop_conversions.c:705
apop_data * apop_data_rm_page(apop_data *data, const char *title, const char free_p)
Definition: apop_data.c:1545
long double apop_linear_constraint(gsl_vector *beta, apop_data *constraint, double margin)
Definition: apop_linear_constraint.c:125
apop_data * apop_data_to_dummies(apop_data *d, int col, char type, int keep_first, char append, char remove)
Definition: apop_regression.c:287
apop_data * apop_query_to_text(const char *fmt,...)
Definition: apop_db.c:271
void apop_model_print(apop_model *print_me, FILE *out)
Definition: apop_model.c:122
int own_kernel
Definition: apop.h:1835
gsl_matrix * draws_made
Definition: apop.h:1799
long double apop_matrix_sum(const gsl_matrix *m)
Definition: apop_stats.c:394
Definition: apop.h:1926
double apop_vector_map_sum(const gsl_vector *in, double(*fn)(double))
Definition: apop_mapply.c:433
void apop_data_add_named_elmt(apop_data *d, char *name, double val)
Definition: apop_data.c:1107
apop_dconstrain
Definition: model_doc.h:896
void apop_name_print(apop_name *n)
Definition: apop_name.c:74
apop_data * apop_bootstrap_cov(apop_data *data, apop_model *model, gsl_rng *rng, int iterations, char keep_boots, char ignore_nans)
Definition: apop_bootstrap.c:121
char apop_data_free_base(apop_data *freeme)
Definition: apop_data.c:209
apop_binomial
Definition: model_doc.h:1752
int thread_count
Definition: apop.h:151
int want_predict_ci
Definition: apop.h:2067
char * apop_text_paste(apop_data const *strings, char *between, char *before, char *after, char *between_cols, int(*prune)(apop_data *, int, int, void *), void *prune_parameter)
Definition: apop_asst.c:68
apop_model * kernel
Definition: apop.h:1831
void apop_matrix_print(const gsl_matrix *data, Output_declares)
Definition: apop_output.c:359
apop_data * apop_f_test(apop_model *est, apop_data *contrast)
Definition: apop_tests.c:116
int apop_draw(double *out, gsl_rng *r, apop_model *m)
Definition: apop_model.c:412
apop_data * apop_data_summarize(apop_data *data)
Definition: apop_stats.c:465
gsl_matrix * apop_matrix_rm_columns(gsl_matrix *in, int *drop)
Definition: apop_linear_algebra.c:351
size_t * block_starts
Definition: apop.h:1912
gsl_matrix * apop_vector_to_matrix(const gsl_vector *in, char row_col)
Definition: apop_conversions.c:73
gsl_vector * apop_query_to_vector(const char *fmt,...)
Definition: apop_db.c:405
void apop_score(apop_data *d, gsl_vector *out, apop_model *m)
Definition: apop_model.c:289
apop_data * apop_data_to_bins(apop_data *indata, apop_data *binspec, int bin_count, char close_top_bin)
Definition: apop_hist.c:324
apop_beta
Definition: model_doc.h:196
apop_data * apop_query_to_data(const char *fmt,...)
Definition: apop_db.c:333
apop_data * apop_data_sort(apop_data *data, apop_data *sort_order, char asc, char inplace, double *col_order)
Definition: apop_sort.c:145
apop_data * apop_model_draws(apop_model *model, int count, apop_data *draws)
Definition: apop_asst.c:418
void apop_data_memcpy(apop_data *out, const apop_data *in)
Definition: apop_data.c:260
apop_data * apop_text_alloc(apop_data *in, const size_t row, const size_t col)
Definition: apop_data.c:1186
void apop_vector_apply(gsl_vector *v, void(*fn)(double *))
Definition: apop_mapply.c:385
apop_data * info
Definition: apop.h:111
apop_mixture
Definition: model_doc.h:1007
gsl_matrix * apop_matrix_stack(gsl_matrix *m1, gsl_matrix *m2, char posn, char inplace)
Definition: apop_linear_algebra.c:275
apop_data * apop_rake(char const *margin_table, char *const *var_list, int var_ct, char const *all_vars, char *const *contrasts, int contrast_ct, char const *structural_zeros, int max_iterations, double tolerance, char const *count_col, int run_number, char const *init_table, char const *init_count_col, double nudge, char const *table_name)
Definition: apop_rake.c:539
apop_data * apop_data_stack(apop_data *m1, apop_data *m2, char posn, char inplace)
Definition: apop_data.c:400
double * apop_data_ptr(apop_data *data, int row, int col, const char *rowname, const char *colname, const char *page)
Definition: apop_data.c:846
apop_model * apop_model_to_pmf(apop_model *model, apop_data *binspec, long int draws, int bin_count, gsl_rng *rng)
Definition: apop_hist.c:35
apop_loess
Definition: model_doc.h:362
struct apop_mcmc_settings apop_mcmc_settings
gsl_vector * apop_matrix_map(const gsl_matrix *m, double(*fn)(gsl_vector *))
Definition: apop_mapply.c:341
double apop_data_get(const apop_data *data, size_t row, int col, const char *rowname, const char *colname, const char *page)
Definition: apop_data.c:898
void apop_matrix_normalize(gsl_matrix *data, const char row_or_col, const char normalization)
Definition: apop_stats.c:376
struct apop_mcmc_proposal_s apop_mcmc_proposal_s
apop_model * apop_ml_impute(apop_data *d, apop_model *meanvar)
Definition: apop_missing_data.c:134
double apop_vector_kurtosis(const gsl_vector *in)
Definition: apop_stats.c:80
long double(* cdf)(apop_data *d, apop_model *params)
Definition: apop.h:121
Definition: apop.h:1815
int draws
Definition: apop.h:1796
gsl_rng * apop_rng_alloc(int seed)
Definition: apop_bootstrap.c:21
apop_data * apop_test_fisher_exact(apop_data *intab)
Definition: apop_fexact.c:1893
double xr
Definition: apop.h:2099
void apop_data_print(const apop_data *data, Output_declares)
Definition: apop_output.c:327
long double apop_vector_sum(const gsl_vector *in)
Definition: apop_stats.c:38
int histosegments
Definition: apop.h:1887
apop_data * apop_model_hessian(apop_data *data, apop_model *model, double delta)
Definition: apop_mle.c:195
void apop_vector_print(gsl_vector *data, Output_declares)
Definition: apop_output.c:210
double xl
Definition: apop.h:2098
char * method
Definition: apop.h:1695
apop_model * apop_estimate(apop_data *d, apop_model *m)
Definition: apop_model.c:223
gsl_vector * apop_vector_unique_elements(const gsl_vector *v)
Definition: apop_regression.c:75
void apop_crosstab_to_db(apop_data *in, char *tabname, char *row_col_name, char *col_col_name, char *data_col_name)
Definition: apop_conversions.c:205
double apop_det_and_inv(const gsl_matrix *in, gsl_matrix **out, int calc_det, int calc_inv)
Definition: apop_linear_algebra.c:54
apop_logit
Definition: model_doc.h:1959
gsl_vector * apop_vector_realloc(gsl_vector *v, size_t newheight)
Definition: apop_data.c:1431
int apop_query(const char *fmt,...)
Definition: apop_db.c:228
apop_stack
Definition: model_doc.h:1211
double * starting_pt
Definition: apop.h:1692
apop_data * apop_test_kolmogorov(apop_model *m1, apop_model *m2)
Definition: apop_hist.c:258
size_t more_size
Definition: apop.h:131
Definition: apop.h:138
Definition: apop.h:1752
char want_cov
Definition: apop.h:1755
int proposal_count
Definition: apop.h:1897
void apop_vector_normalize(gsl_vector *in, gsl_vector **out, const char normalization_type)
Definition: apop_stats.c:324
apop_data * apop_data_get_factor_names(apop_data *data, int col, char type)
Definition: apop_regression.c:434
double apop_test(double statistic, char *distribution, double p1, double p2, char tail)
Definition: apop_tests.c:422
apop_data * apop_matrix_to_data(gsl_matrix *m)
Definition: apop_data.c:153
apop_data * apop_matrix_pca(gsl_matrix *data, int const dimensions_we_want)
Definition: apop_linear_algebra.c:119
Definition: apop.h:1882
char do_metro
Definition: apop.h:2103
void apop_matrix_show(const gsl_matrix *data)
Definition: apop_output.c:386
char want_expected_value
Definition: apop.h:1756
apop_coordinate_transform
Definition: model_doc.h:1451
apop_data * apop_predict(apop_data *d, apop_model *m)
Definition: apop_model.c:478
long double(* p)(apop_data *d, apop_model *params)
Definition: apop.h:117
void apop_matrix_mean_and_var(const gsl_matrix *data, double *mean, double *var)
Definition: apop_stats.c:436
apop_opts_type apop_opts
Definition: apop_db.c:10
gsl_vector * apop_vector_map(const gsl_vector *v, double(*fn)(double))
Definition: apop_mapply.c:370
apop_data * apop_data_covariance(const apop_data *in)
Definition: apop_stats.c:636
int ninit
Definition: apop.h:2101
apop_data ** apop_data_split(apop_data *in, int splitpoint, char r_or_c)
Definition: apop_data.c:508
void apop_model_free(apop_model *free_me)
Definition: apop_model.c:58
double apop_vector_skew_pop(gsl_vector const *v, gsl_vector const *weights)
Definition: apop_stats.c:118
apop_data * apop_histograms_test_goodness_of_fit(apop_model *h0, apop_model *h1)
Definition: apop_hist.c:76
int max_iterations
Definition: apop.h:1721
long double(* log_likelihood)(apop_data *d, apop_model *params)
Definition: apop.h:119
apop_data * data
Definition: apop.h:109
void apop_matrix_apply(gsl_matrix *m, void(*fn)(gsl_vector *))
Definition: apop_mapply.c:355
apop_bernoulli
Definition: model_doc.h:7
apop_data * parameters
Definition: apop.h:110
apop_t_distribution
Definition: model_doc.h:587
double apop_p(apop_data *d, apop_model *m)
Definition: apop_model.c:238
gsl_rng * rng
Definition: apop.h:2130
Definition: apop.h:90
void apop_matrix_apply_all(gsl_matrix *in, void(*fn)(double *))
Definition: apop_mapply.c:421
apop_model * apop_update(apop_data *data, apop_model *prior, apop_model *likelihood, gsl_rng *rng)
Definition: apop_update.c:177
long double apop_multivariate_lngamma(double a, int p)
Definition: apop_stats.c:808
void apop_name_stack(apop_name *n1, apop_name *nadd, char type1, char typeadd)
Definition: apop_name.c:128
int apop_text_to_db(char const *text_file, char *tabname, int has_row_names, int has_col_names, char **field_names, int const *field_ends, apop_data *field_params, char *table_params, char const *delimiters, char if_table_exists)
Definition: apop_conversions.c:1162
double apop_kl_divergence(apop_model *from, apop_model *to, int draw_ct, gsl_rng *rng)
Definition: apop_stats.c:699
apop_probit
Definition: model_doc.h:1321
gsl_matrix * apop_matrix_copy(const gsl_matrix *in)
Definition: apop_conversions.c:343
apop_model * base_pmf
Definition: apop.h:1829
int(* base_adapt_fn)(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms)
Definition: apop.h:1921
int npoint
Definition: apop.h:2102
apop_model * base_model
Definition: apop.h:1891
int(* adapt_fn)(struct apop_mcmc_proposal_s *ps, struct apop_mcmc_settings *ms)
Definition: apop.h:1871
double tolerance
Definition: apop.h:1718
double apop_map_sum(apop_data *in, apop_fn_d *fn_d, apop_fn_v *fn_v, apop_fn_r *fn_r, apop_fn_dp *fn_dp, apop_fn_vp *fn_vp, apop_fn_rp *fn_rp, apop_fn_dpi *fn_dpi, apop_fn_vpi *fn_vpi, apop_fn_rpi *fn_rpi, apop_fn_di *fn_di, apop_fn_vi *fn_vi, apop_fn_ri *fn_ri, void *param, char part, int all_pages)
Definition: apop_mapply.c:475
Definition: apop.h:2135
Definition: apop.h:2064
apop_data * apop_data_get_page(const apop_data *data, const char *title, const char match)
Definition: apop_data.c:1460
double apop_vector_correlation(const gsl_vector *ina, const gsl_vector *inb)
Definition: apop_stats.c:191
apop_data * apop_estimate_coefficient_of_determination(apop_model *)
Definition: apop_regression.c:522
void apop_estimate_parameter_tests(apop_model *est)
Definition: apop_regression.c:22
int apop_data_set_row(apop_data *row, apop_data *d, int row_number)
Definition: apop_data.c:1043
gsl_vector * apop_vector_copy(const gsl_vector *in)
Definition: apop_conversions.c:324
Definition: apop.h:1784
apop_data * apop_data_alloc(const size_t size1, const size_t size2, const int size3)
Definition: apop_data.c:35
apop_data * apop_data_add_page(apop_data *dataset, apop_data *newpage, const char *title)
Definition: apop_data.c:1511
Definition: apop.h:102
Definition: apop.h:2145
apop_data * apop_map(apop_data *in, apop_fn_d *fn_d, apop_fn_v *fn_v, apop_fn_r *fn_r, apop_fn_dp *fn_dp, apop_fn_vp *fn_vp, apop_fn_rp *fn_rp, apop_fn_dpi *fn_dpi, apop_fn_vpi *fn_vpi, apop_fn_rpi *fn_rpi, apop_fn_di *fn_di, apop_fn_vi *fn_vi, apop_fn_ri *fn_ri, void *param, int inplace, char part, int all_pages)
Definition: apop_mapply.c:115
int destroy_data
Definition: apop.h:1753
double apop_matrix_determinant(const gsl_matrix *in)
Definition: apop_linear_algebra.c:100
double apop_vector_var_m(const gsl_vector *in, const double mean)
Definition: apop_stats.c:184
apop_model * proposal
Definition: apop.h:1856
apop_data * apop_text_to_data(char const *text_file, int has_row_names, int has_col_names, int const *field_ends, char const *delimiters)
Definition: apop_conversions.c:608
int * draws_refcount
Definition: apop.h:1800
gsl_vector * apop_vector_stack(gsl_vector *v1, gsl_vector *v2, char inplace)
Definition: apop_linear_algebra.c:210
void apop_vector_exp(gsl_vector *v)
Definition: apop_linear_algebra.c:191
apop_data * apop_data_to_factors(apop_data *data, char intype, int incol, int outcol)
Definition: apop_regression.c:387
double xprev
Definition: apop.h:2104
apop_improper_uniform
Definition: model_doc.h:1269
apop_data * apop_vector_to_data(gsl_vector *v)
Definition: apop_data.c:162
gsl_vector * apop_array_to_vector(double *in, int size)
Definition: apop_conversions.c:42
int apop_table_exists(char const *name, char remove)
Definition: apop_db.c:126
int apop_db_open(char const *filename)
Definition: apop_db.c:79
double apop_vector_var(gsl_vector const *v, gsl_vector const *weights)
Definition: apop_stats.c:559
int apop_db_close(char vacuum)
Definition: apop_db.c:175
int apop_system(const char *fmt,...)
Definition: apop_asst.c:164
int apop_name_add(apop_name *n, char const *add_me, char type)
Definition: apop_name.c:32
apop_name * apop_name_alloc(void)
Definition: apop_name.c:13
apop_mcmc_proposal_s * proposals
Definition: apop.h:1894
apop_model * apop_estimate_restart(apop_model *e, apop_model *copy, char *starting_pt, double boundary)
Definition: apop_mle.c:716
apop_data * apop_jackknife_cov(apop_data *data, apop_model *model)
Definition: apop_bootstrap.c:53
double burnin
Definition: apop.h:1885
apop_data * base_data
Definition: apop.h:1828
apop_data * apop_data_correlation(const apop_data *in)
Definition: apop_stats.c:660
void apop_data_rm_columns(apop_data *d, int *drop)
Definition: apop_data.c:704
void apop_prep(apop_data *d, apop_model *m)
Definition: apop_model.c:441
apop_kernel_density
Definition: model_doc.h:1838
Definition: apop.h:2126
apop_multivariate_normal
Definition: model_doc.h:244
gsl_rng * rng
Definition: apop.h:1797
Definition: apop.h:58
int dsize
Definition: apop.h:104
Definition: apop.h:1855
int verbose
Definition: apop.h:1723
apop_data * apop_db_to_crosstab(char *tabname, char *r1, char *r2, char *datacol)
Definition: apop_conversions.c:136
apop_data * apop_test_anova_independence(apop_data *d)
Definition: apop_tests.c:217
long double total_weight
Definition: apop.h:1819
apop_exponential
Definition: model_doc.h:1392
int reject_count
Definition: apop.h:1875
apop_model * apop_beta_from_mean_var(double m, double v)
Definition: apop_asst.c:342
Definition: apop.h:2117
apop_model * apop_parameter_model(apop_data *d, apop_model *m)
Definition: apop_model.c:353
void apop_text_free(char ***freeme, int rows, int cols)
Definition: apop_data.c:185
apop_model * cmf
Definition: apop.h:2150
int apop_name_find(const apop_name *n, const char *findme, const char type)
Definition: apop_name.c:188
double apop_matrix_mean(const gsl_matrix *data)
Definition: apop_stats.c:409
apop_model * model1
Definition: apop.h:2113
double apop_vector_mean(gsl_vector const *v, gsl_vector const *weights)
Definition: apop_stats.c:520
apop_normal
Definition: model_doc.h:646
int * cmf_refct
Definition: apop.h:2151
apop_dirichlet
Definition: model_doc.h:704
int apop_vector_bounded(const gsl_vector *in, long double max)
Definition: apop_linear_algebra.c:386
apop_wls
Definition: model_doc.h:447
FILE * log_file
Definition: apop.h:149
double apop_vector_distance(const gsl_vector *ina, const gsl_vector *inb, const char metric, const double norm)
Definition: apop_stats.c:224
apop_data * apop_text_unique_elements(const apop_data *d, size_t col)
Definition: apop_regression.c:103
gsl_matrix * apop_matrix_map_all(const gsl_matrix *in, double(*fn)(double))
Definition: apop_mapply.c:402
char * splitpage
Definition: apop.h:2112
Definition: apop.h:1806
int apop_regex(const char *string, const char *regex, apop_data **substrings, const char use_case)
Definition: apop_asst.c:262
int apop_data_set(apop_data *data, size_t row, int col, const double val, const char *rowname, const char *colname, const char *page)
Definition: apop_data.c:980
Definition: apop.h:2111
apop_data * apop_data_pmf_compress(apop_data *in)
Definition: apop_pmf.c:337
apop_model * pmf
Definition: apop.h:1889
int accept_count
Definition: apop.h:1899
apop_zipf
Definition: model_doc.h:68
double apop_matrix_to_positive_semidefinite(gsl_matrix *m)
Definition: apop_stats.c:887
double apop_vector_skew(const gsl_vector *in)
Definition: apop_stats.c:71
void(* step_fn)(double const *, struct apop_mcmc_proposal_s *, struct apop_mcmc_settings *)
Definition: apop.h:1863
int draw_ct
Definition: apop.h:2132
apop_uniform
Definition: model_doc.h:1502
gsl_matrix * apop_query_to_matrix(const char *fmt,...)
Definition: apop_db.c:376
int(* draw)(double *out, gsl_rng *r, apop_model *params)
Definition: apop.h:124
gsl_matrix * apop_matrix_realloc(gsl_matrix *m, size_t newheight, size_t newwidth)
Definition: apop_data.c:1378
long double apop_multivariate_gamma(double a, int p)
Definition: apop_stats.c:796
gsl_matrix * apop_matrix_inverse(const gsl_matrix *in)
Definition: apop_linear_algebra.c:85
apop_lognormal
Definition: model_doc.h:537
apop_model * model
Definition: apop.h:2107
apop_model ** model_list
Definition: apop.h:2147
double apop_generalized_harmonic(int N, double s) __attribute__((__pure__))
Definition: apop_asst.c:114
apop_model * cdf_model
Definition: apop.h:1798
char start_at
Definition: apop.h:1915
void apop_vector_log10(gsl_vector *v)
Definition: apop_linear_algebra.c:165
apop_data * apop_data_rank_expand(apop_data *in)
Definition: apop_conversions.c:291
apop_model * model2
Definition: apop.h:2114
Definition: apop.h:2096
apop_data * apop_data_prune_columns_base(apop_data *d, char **colnames)
Definition: apop_data.c:746
int * param_sizes
Definition: apop.h:2149
apop_data * apop_data_listwise_delete(apop_data *d, char inplace)
Definition: apop_missing_data.c:29
apop_data * apop_data_copy(const apop_data *in)
Definition: apop_data.c:331
int apop_text_add(apop_data *in, const size_t row, const size_t col, const char *fmt,...)
Definition: apop_data.c:1159
apop_model * base_model
Definition: apop.h:2127
int gsl_vector * apop_vector_moving_average(gsl_vector *, size_t)
Definition: apop_smoothing.c:11
double apop_log_likelihood(apop_data *d, apop_model *m)
Definition: apop_model.c:255
double convex
Definition: apop.h:2100
double apop_query_to_float(const char *fmt,...)
Definition: apop_db.c:445
void apop_vector_show(const gsl_vector *data)
Definition: apop_output.c:230
apop_model * apop_model_fix_params_get_base(apop_model *model_in)
Definition: apop_fix_params.c:273
double apop_vector_cov(gsl_vector const *v1, gsl_vector const *v2, gsl_vector const *weights)
Definition: apop_stats.c:593
apop_pmf
Definition: model_doc.h:797
int apop_matrix_is_positive_semidefinite(gsl_matrix *m, char semi)
Definition: apop_stats.c:852
apop_yule
Definition: model_doc.h:1902
apop_iv
Definition: model_doc.h:1698
apop_name * apop_name_copy(apop_name *in)
Definition: apop_name.c:168
apop_data * apop_query_to_mixed_data(const char *typelist, const char *fmt,...)
Definition: apop_db.c:489
int reject_count
Definition: apop.h:1900
void apop_data_show(const apop_data *data)
Definition: apop_output.c:103
void apop_vector_log(gsl_vector *v)
Definition: apop_linear_algebra.c:178
double apop_cdf(apop_data *d, apop_model *m)
Definition: apop_model.c:519
gsl_vector * apop_numerical_gradient(apop_data *data, apop_model *model, double delta)
Definition: apop_mle.c:131
apop_data * apop_data_rm_rows(apop_data *in, int *drop, int(*do_drop)(apop_data *, void *), void *drop_parameter)
Definition: apop_data.c:1595
int neval
Definition: apop.h:2105
apop_gamma
Definition: model_doc.h:1632
apop_poisson
Definition: model_doc.h:2036
apop_multinomial
Definition: model_doc.h:1550
int gsl_matrix apop_data apop_data apop_data gsl_vector double int apop_data_to_db(const apop_data *set, const char *tabname, char)
Definition: apop_db.c:610
double apop_rng_GHgB3(gsl_rng *r, double *a)
Definition: apop_asst.c:319
double ci_level
Definition: apop.h:2069
void apop_name_free(apop_name *free_me)
Definition: apop_name.c:106
double apop_matrix_map_sum(const gsl_matrix *in, double(*fn)(gsl_vector *))
Definition: apop_mapply.c:457
void * more
Definition: apop.h:128
double apop_vector_kurtosis_pop(gsl_vector const *v, gsl_vector const *weights)
Definition: apop_stats.c:154
gsl_vector * apop_data_pack(const apop_data *in, gsl_vector *out, char all_pages, char use_info_pages)
Definition: apop_conversions.c:783
apop_data * apop_data_calloc(const size_t size1, const size_t size2, const int size3)
Definition: apop_data.c:88
Definition: apop.h:1827
apop_data ** path
Definition: apop.h:1736
Definition: apop.h:1691
Definition: apop.h:1795
apop_data * apop_data_rank_compress(apop_data *in)
Definition: apop_conversions.c:270
apop_model * apop_model_fix_params(apop_model *model_in)
Definition: apop_fix_params.c:230
apop_model * apop_model_copy(apop_model *in)
Definition: apop_model.c:152
void apop_maximum_likelihood(apop_data *data, apop_model *dist)
Definition: apop_mle.c:646
apop_ols
Definition: model_doc.h:1078
char db_engine
Definition: apop.h:146
double last_ll
Definition: apop.h:1888
void(* estimate)(apop_data *data, apop_model *params)
Definition: apop.h:115
char * nan_string
Definition: apop.h:145
apop_model * input_distribution
Definition: apop.h:1757
int apop_arms_draw(double *out, gsl_rng *r, apop_model *m)
Adaptive rejection metropolis sampling.
Definition: apop_arms.c:93
apop_data * apop_model_numerical_covariance(apop_data *data, apop_model *model, double delta)
Definition: apop_mle.c:253
char draw_index
Definition: apop.h:1817
double * apop_vector_percentiles(gsl_vector *data, char rounding)
Definition: apop_asst.c:184
apop_data * apop_anova(char *table, char *data, char *grouping1, char *grouping2)
Definition: apop_tests.c:291
apop_data * apop_dot(const apop_data *d1, const apop_data *d2, char form1, char form2)
Definition: apop_linear_algebra.c:474
int verbose
Definition: apop.h:139
apop_data * apop_data_transpose(apop_data *in, char transpose_text, char inplace)
Definition: apop_data.c:1274
char stop_on_warning
Definition: apop.h:140
char gibbs_chunks
Definition: apop.h:1901
int proposal_is_cp
Definition: apop.h:1913
gsl_vector * cmf
Definition: apop.h:1816
int * cmf_refct
Definition: apop.h:1820
long int periods
Definition: apop.h:1884
double dim_cycle_tolerance
Definition: apop.h:1725

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