![]() |
|
Go to the source code of this file.
| #define Apop_model_add_group | ( | model, | |||
| type, | |||||
| ... | ) | apop_settings_group_alloc(model, #type, type ## _settings_free, type ## _settings_copy, type ##_settings_init ((type ## _settings) {__VA_ARGS__})); |
Add a settings group. The first two arguments (the model you are attaching to and the settings group name) are mandatory, and then you can use the Designated initializers syntax to specify default values (if any). Returns a pointer to the newly-prepped group.
| #define Apop_settings_add_group | ( | model, | |||
| type, | |||||
| ... | ) | apop_settings_group_alloc(model, #type, type ## _settings_free, type ## _settings_copy, type ##_settings_alloc (__VA_ARGS__)); |
Add a settings group. Deprecated; use Apop_model_add_group instead. You will need to provide arguments for the specific settings group you are dealing with, such as apop_mle_settings_alloc, apop_ls_settings_alloc, apop_histogram_settings_alloc.
| #define Apop_settings_declarations | ( | ysg | ) |
ysg##_settings * ysg##_settings_init(ysg##_settings); \ void * ysg##_settings_copy(ysg##_settings *); \ void ysg##_settings_free(ysg##_settings *);
| #define Apop_settings_get | ( | model, | |||
| type, | |||||
| setting | ) | (((type ## _settings *) apop_settings_get_group(model, #type))->setting) |
Retrieves a setting from a model. See Apop_settings_get_group pull the entire group.
| #define Apop_settings_get_group | ( | m, | |||
| type | ) | apop_settings_get_group(m, #type) |
Retrieves a settings group from a model. See Apop_settings_get to just pull a single item from within the settings group.
| #define Apop_settings_rm_group | ( | m, | |||
| type | ) | apop_settings_rm_group(m, #type) |
Removes a settings group from a model's list.
| #define Apop_settings_set | ( | model, | |||
| type, | |||||
| setting, | |||||
| data | ) |
do { type ## _settings *apop_tmp_settings = apop_settings_get_group(model, #type); \ apop_assert_void(apop_tmp_settings, 0, 's', "You're trying to modify a setting in " \ #model "'s setting group of type " #type " but that model doesn't have such a group."); \ apop_tmp_settings->setting = (data); \ } while (0);
Modifies a single element of a settings group to the given value.
| apop_histogram_settings* apop_histogram_settings_alloc | ( | apop_data * | data, | |
| int | bins | |||
| ) |
Allocate the parameters for the apop_histogram model.
| data | The input data. I'll use all data in both the the matrix and vector element of the apop_data set, and the matrix can have any dimensions ( , , ...). | |
| bins | How many bins should the PDF have? |
| apop_histogram_settings* apop_kernel_density_settings_alloc | ( | apop_data * | data, | |
| apop_model * | histobase, | |||
| apop_model * | kernelbase, | |||
| void(*)(double, apop_model *) | set_params | |||
| ) |
Allocate and fill a kernel density, which is a smoothed histogram.
You may either provide a histogram and a NULL data set, or a NULL histogram and a real data set, in which case I will convert the data set into a histogram and use the histogram thus created.
| data | a data set, which, if not NULL and !histobase , will be converted to a histogram. | |
| histobase | This is the preferred format for input data. It is the histogram to be smoothed. | |
| kernelbase | The kernel to use for smoothing, with all parameters set and a p method. Popular favorites are apop_normal and apop_uniform. | |
| set_params | A function that takes in a single number and the model, and sets the parameters accordingly. The function will call this for every point in the data set. Below is the default, which is used if this is NULL. It simply sets the first element of the model's parameter vector to the input number; this is appropriate for a Normal distribution, where we want to center the distribution on each data point in turn. |
void apop_set_first_params(double in, apop_model *m){ m->parameters->vector->data[0] = in; }
| void apop_settings_copy_group | ( | apop_model * | outm, | |
| apop_model * | inm, | |||
| char * | copyme | |||
| ) |
Copy a settings group with the given name from the second model to the first. (i.e., the arguments are in memcpy order).
You probably won't need this often---just use apop_model_copy.
| Apop_settings_declarations | ( | apop_ls | ) |
For dependent-category models, send in this settings struct to specify which column is the dependent variable.
If you don't use it, these models will assume that the vector or first numeric column is already a coherent set of factors, but by sending this in, those functions have a little more information, such as names to use in the output.
See also the apop_category_settings_alloc function.
< source_type 't' = text; anything else ('d' is a good choice) is * numeric data.
< The number of the column to convert to factors. As usual, the vector is -1.
< The input data set that you're probably about to run a regression on
| void* apop_settings_get_group | ( | apop_model * | m, | |
| char * | type | |||
| ) |
This function gets the settings group with the given name. If it isn't found, then it returns NULL, so you can easily put it in a conditional like
if (!apop_settings_get_group(m, "apop_ols")) ...
The settings macros don't need quotation marks, e.g.
if (!Apop_settings_get_group(m, apop_ols)) ...
It is recommended that you stick with this form, because other operations on settings require this form.
| void* apop_settings_group_alloc | ( | apop_model * | model, | |
| char * | type, | |||
| void * | free_fn, | |||
| void * | copy_fn, | |||
| void * | the_group | |||
| ) |
Don't use this function. It's what the Apop_model_add_group macro uses internally. Use that.
| void apop_settings_rm_group | ( | apop_model * | m, | |
| char * | delme | |||
| ) |
Remove a settings group from a model.
There are two ways to use this, the function or the macro:
apop_settings_rm_group(your_model, "apop_mle"); //or Apop_settings_rm_group(your_model, apop_mle);
The macro just calls the function, but is in line with some of the other macros that are preferred over the function.
If the model has no settings or your preferred settings group is not found, this function does nothing.
| apop_update_settings* apop_update_settings_alloc | ( | apop_data * | d | ) |
Allocate an apop_update_settings struct. See also apop_update_settings_init, which is not deprecated.
| apop_update_settings* apop_update_settings_init | ( | apop_update_settings | in | ) |
Allocate an apop_update_settings struct.