1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
/* ------------------------------------------------------------- */
/* File: example_FuncStr.c */
/* ------------------------------------------------------------- */
/* Include UNURAN header file. */
#include <unuran.h>
/* ------------------------------------------------------------- */
/* Example how to define the PDF for a continuous univariate */
/* distribution using a function string. */
/* ------------------------------------------------------------- */
int main(void)
{
UNUR_DISTR *distr; /* distribution object */
char *pdfstr;
/* Get empty distribution object for a continuous distribution */
distr = unur_distr_cont_new();
/* Set PDF using function string */
unur_distr_cont_set_pdfstr(distr,"1-x*x");
unur_distr_cont_set_domain(distr,-1.,1.);
/* Read function string from distribution object */
pdfstr = unur_distr_cont_get_pdfstr(distr);
printf("functionstring: %s\n",pdfstr);
/* Destroy distribution object and clear memory */
unur_distr_free(distr);
free (pdfstr);
exit (EXIT_SUCCESS);
} /* end of main() */
/* ------------------------------------------------------------- */
|