41 lines
828 B
C
41 lines
828 B
C
|
#pragma once
|
|||
|
|
|||
|
#include <gsl/gsl_matrix.h>
|
|||
|
#include <gsl/gsl_rng.h>
|
|||
|
|
|||
|
/* Parameters for bivariate
|
|||
|
* gaussian PDF
|
|||
|
*/
|
|||
|
struct par {
|
|||
|
double x0; // x mean
|
|||
|
double y0; // y mean
|
|||
|
double sigma_x; // x standard dev
|
|||
|
double sigma_y; // y standard dev
|
|||
|
double rho; // correlation: cov(x,y)/σx⋅σy
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
/* A sample of N 2D points is an
|
|||
|
* N×2 matrix, with vectors as rows.
|
|||
|
*/
|
|||
|
typedef struct {
|
|||
|
struct par p;
|
|||
|
gsl_matrix *data;
|
|||
|
} sample_t;
|
|||
|
|
|||
|
|
|||
|
/* Create a sample of `n` points */
|
|||
|
sample_t* sample_t_alloc(size_t n, struct par p);
|
|||
|
|
|||
|
|
|||
|
/* Delete a sample */
|
|||
|
void sample_t_free(sample_t *x);
|
|||
|
|
|||
|
|
|||
|
/* `generate_normal(r, n, p)` will create
|
|||
|
* a sample of `n` points, distributed
|
|||
|
* according to a bivariate gaussian distribution
|
|||
|
* of parameters `p`.
|
|||
|
*/
|
|||
|
sample_t* generate_normal(gsl_rng *r, size_t n, struct par *p);
|