Hi group!

I would like to know how to do  adaptive integration of beta PDF
distribution function. (The PDF not the random number generator)

I'm trying to follow this example (given in the official docs),

#include <stdio.h>#include <math.h>#include
<gsl/gsl_integration.h>#include <gsl/gsl_randist.h>
double f (double x, void * params) {
    double alpha = *(double *) params;
    double f = log(alpha*x) / sqrt(x);
    return f;}
int main (void){
    gsl_integration_workspace * w
    = gsl_integration_workspace_alloc (1000);

    double result, error;
    double expected = -4.0;
    double alpha = 1.0;

    gsl_function F;
    F.function = &f;
    //F.function = &gsl_ran_gaussian_pdf;
    //F.function = gsl_ran_beta_pdf
    F.params = &alpha;

    gsl_integration_qags (&F, 0, 1, 0, 1e-7, 1000,
                    w, &result, &error);

    printf ("result          = % .18f\n", result);
    printf ("exact result    = % .18f\n", expected);
    printf ("estimated error = % .18f\n", error);
    printf ("actual error    = % .18f\n", result - expected);
    printf ("intervals       = %zu\n", w->size);

    gsl_integration_workspace_free (w);

    return 0;

}

I don't know how to use the inbuilt function and how to specify more than 1
parameters (alpha and beta) to the function. I am very new to gsl, so
please bear with me.

I tried to integrate gsl_ran_gaussian_pdf from 0 to 1 with sigma = 0.001,
but I wasn't able to do it.

Any help or further direction to appropriate docs would be appreciated!

Thanks,
Vasu

Reply via email to