Example #1
0
void librdist_negative_binomial(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_negative_binomial)){
		return;
	}
	const double p = librdist_atom_getfloat(av);
	const double n = librdist_atom_getfloat(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_negative_binomial(rng, p, n);
}
Example #2
0
void librdist_f(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_f)){
		return;
	}
	const double nu1 = librdist_atom_getfloat(av);
	const double nu2 = librdist_atom_getfloat(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_fdist(rng, nu1, nu2);
}
Example #3
0
void librdist_gumbel2(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_gumbel2)){
		return;
	}
	const double a = librdist_atom_getfloat(av);
	const double b = librdist_atom_getfloat(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_gumbel2(rng, a, b);
}
Example #4
0
void librdist_lognormal(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_lognormal)){
		return;
	}
	const double zeta = librdist_atom_getfloat(av);
	const double sigma = librdist_atom_getfloat(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_lognormal(rng, zeta, sigma);
}
Example #5
0
void librdist_levy(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_levy)){
		return;
	}
	const double c = librdist_atom_getfloat(av);
	const double alpha = librdist_atom_getfloat(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_levy(rng, c, alpha);
}
Example #6
0
void librdist_bivariate_gaussian(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_bivariate_gaussian)){
		return;
	}
	const double sigma_x = librdist_atom_getfloat(av);
	const double sigma_y = librdist_atom_getfloat(av + 1);
	const double rho = librdist_atom_getfloat(av + 2);
	double _x, _y;
	gsl_ran_bivariate_gaussian(rng, sigma_x, sigma_y, rho, &_x, &_y);
	int i;
	for(i = 0; i < bufc / 2; i += 2){
		buf[i] = _x;
		buf[i + 1] = _y;
	}
}
Example #7
0
void librdist_logarithmic(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_logarithmic)){
		return;
	}
	const double p = librdist_atom_getfloat(av);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_logarithmic(rng, p);
}
Example #8
0
void librdist_poisson(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_poisson)){
		return;
	}
	const double mu = librdist_atom_getfloat(av);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_poisson(rng, mu);
}
Example #9
0
void librdist_rayleigh(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_rayleigh)){
		return;
	}
	const double sigma = librdist_atom_getfloat(av);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_rayleigh(rng, sigma);
}
Example #10
0
void librdist_pascal(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	if(argc != librdist_getnargs(ps_pascal)){
		return;
	}
	const double p = librdist_atom_getfloat(av);
	const unsigned int n = (unsigned int)librdist_atom_getlong(av + 1);
	int i;
	for(i = 0; i < bufc; i++)
	       	buf[i] = (float)gsl_ran_pascal(rng, p, n);
}
Example #11
0
void rdist_nonparametric(t_rdist *x, t_symbol *msg, short argc, t_atom *argv){
	double f[argc];
	int i;
	x->r_dist = msg;
	for(i = 0; i < argc; i++){
		f[i] = librdist_atom_getfloat(argv + i);
		//post("%d, %f", i, f[i]);
	}
	if(x->r_g){
		gsl_ran_discrete_free(x->r_g);
	}
	x->r_g = gsl_ran_discrete_preproc(argc, f);
	x->r_function = librdist_nonparametric;
}
Example #12
0
void librdist_dirichlet(gsl_rng *rng, int argc, void *argv, int bufc, float *buf){
	t_atom *av = (t_atom *)argv;
	int i, j;
	size_t k = argc;
	double alpha[argc];
	double theta[argc];
	for(i = 0; i < k; i++){
		alpha[i] = librdist_atom_getfloat(av + i);
	}
	for(j = 0; j < floor(bufc / k); j++){
		gsl_ran_dirichlet(rng, k, alpha, theta);
		for(i = 0; i < k; i++){
			buf[i] = theta[i];
		}
	}
}