Doxygen Source Code Documentation
model_beta.c File Reference
#include <math.h>
#include "NLfit_model.h"
Go to the source code of this file.
Functions | |
void | signal_model (float *gs, int ts_length, float **x_array, float *ts_array) |
DEFINE_MODEL_PROTOTYPE MODEL_interface * | initialize_model () |
Function Documentation
|
Definition at line 40 of file model_beta.c. References MODEL_interface::call_func, MODEL_interface::label, MODEL_interface::max_constr, MODEL_interface::min_constr, MODEL_SIGNAL_TYPE, MODEL_interface::model_type, MODEL_interface::params, MODEL_interface::plabel, signal_model(), and XtMalloc.
00041 { 00042 MODEL_interface * mi = NULL; 00043 00044 00045 /*----- allocate memory space for model interface -----*/ 00046 mi = (MODEL_interface *) XtMalloc (sizeof(MODEL_interface)); 00047 00048 00049 /*----- define interface for the differential - exponential model -----*/ 00050 00051 /*----- name of this model -----*/ 00052 strcpy (mi->label, "Beta"); 00053 00054 /*----- this is a signal model -----*/ 00055 mi->model_type = MODEL_SIGNAL_TYPE; 00056 00057 /*----- number of parameters in the model -----*/ 00058 mi->params = 5; 00059 00060 /*----- parameter labels -----*/ 00061 strcpy (mi->plabel[0], "t0"); 00062 strcpy (mi->plabel[1], "tf"); 00063 strcpy (mi->plabel[2], "k"); 00064 strcpy (mi->plabel[3], "alpha"); 00065 strcpy (mi->plabel[4], "beta"); 00066 00067 /*----- minimum and maximum parameter constraints -----*/ 00068 mi->min_constr[0] = 27.0; mi->max_constr[0] = 77.0; 00069 mi->min_constr[1] = 78.0; mi->max_constr[1] = 250.0; 00070 mi->min_constr[2] = -5000.0; mi->max_constr[2] = 5000.0; 00071 mi->min_constr[3] = 0.00; mi->max_constr[3] = 10.0; 00072 mi->min_constr[4] = 0.00; mi->max_constr[4] = 10.0; 00073 00074 /*----- function which implements the model -----*/ 00075 mi->call_func = &signal_model; 00076 00077 00078 /*----- return pointer to the model interface -----*/ 00079 return (mi); 00080 } |
|
Definition at line 99 of file model_beta.c. Referenced by initialize_model().
00106 { 00107 int it; /* time index */ 00108 float t; /* time */ 00109 float fval; /* time series value at time t */ 00110 float x; /* rescaled t */ 00111 float t0, tf, k, alpha, beta; /* parameters */ 00112 00113 00114 t0 = gs[0]; 00115 tf = gs[1]; 00116 k = gs[2]; 00117 alpha = gs[3]; 00118 beta = gs[4]; 00119 00120 for (it = 0; it < ts_length; it++) 00121 { 00122 t = x_array[it][1]; 00123 if ((t <= t0) || (t >= tf) || (t0 >= tf)) 00124 fval = 0.0; 00125 else 00126 { 00127 x = (t - t0) / (tf - t0); 00128 fval = k * exp((alpha-1.0)*log(x)) * exp((beta-1.0)*log(1.0-x)); 00129 } 00130 ts_array[it] = fval; 00131 } 00132 } |