61 const int TAB_SIZE = 97;
64 static double y, v[TAB_SIZE];
66 const double RAN_DIVISOR = double(ANN_RAND_MAX + 1UL);
67 if (RAN_DIVISOR < 0) {
68 cout <<
"RAN_DIVISOR " << RAN_DIVISOR << endl;
85 for (j = 0; j < TAB_SIZE; j++)
88 for (j = 0; j < TAB_SIZE; j++)
100 j = int(TAB_SIZE * (y / RAN_DIVISOR));
103 return y / RAN_DIVISOR;
153 r = v1 * v1 + v2 * v2;
155 double fac = sqrt(-2.0 * log(r) / r);
183 const double b = 1.4142136;
185 double laprand = -log(
annRan0()) / b;
187 if (sign < 0.5) laprand = -laprand;
201 for (
int i = 0; i < n; i++) {
202 for (
int d = 0; d <
dim; d++) {
220 for (
int i = 0; i < n; i++) {
221 for (
int d = 0; d <
dim; d++) {
237 for (
int i = 0; i < n; i++) {
238 for (
int d = 0; d <
dim; d++) {
256 double std_dev_w = sqrt(1.0 - correlation * correlation);
257 for (
int i = 0; i < n; i++) {
260 for (
int d = 1; d <
dim; d++) {
261 previous = correlation*previous + std_dev_w*
annRanGauss();
280 double corr_sq = correlation * correlation;
282 for (
int i = 0; i < n; i++) {
285 for (
int d = 1; d <
dim; d++) {
291 previous = correlation * previous + wn;
324 if (clusters == NULL || new_clust) {
325 if (clusters != NULL)
329 for (
int i = 0; i < n_clus; i++) {
330 for (
int d = 0; d <
dim; d++) {
336 for (
int i = 0; i < n; i++) {
338 for (
int d = 0; d <
dim; d++) {
398 for (
int i = 0; i < n; i++) {
399 for (
int d = 0; d <
dim; d++) {
419 if (control == NULL || new_clust) {
420 if (control != NULL) {
425 for (
int c = 0; c < n_clus; c++) {
427 for (
int d = 0; d <
dim; d++) {
429 double Prob = ((double) n_dim)/((double) (dim-d));
441 for (
int c = 0; c < n_clus; c++) {
442 int pick = (n+c)/n_clus;
444 genOrthFlat(pa+offset, pick, dim, control[c], std_dev);
496 for (
int i = 0; i < n; i++) {
497 for (
int d = 0; d <
dim; d++) {
509 double std_dev_small,
517 if (centers == NULL || new_clust) {
526 for (
int i = 0; i < n_clus; i++) {
527 for (
int d = 0; d <
dim; d++) {
531 for (
int c = 0; c < n_clus; c++) {
533 for (
int d = 0; d <
dim; d++) {
535 double Prob = ((double) n_dim)/((double) (dim-d));
538 std_dev[c][d] =
annRanUnif(std_dev_lo, std_dev_hi);
542 std_dev[c][d] = std_dev_small;
549 for (
int c = 0; c < n_clus; c++) {
550 int pick = (n+c)/n_clus;
552 genGauss(pa+offset, pick, dim, centers[c], std_dev[c]);
588 for (
int i = 0; i < n; i++) {
590 for (
int d = 0; d <
dim; d++) {
void annClusGaussPts(ANNpointArray pa, int n, int dim, int n_clus, ANNbool new_clust, double std_dev)
static double annRanGauss()
static double annRanLaplace()
static void genOrthFlat(ANNpointArray pa, int n, int dim, double *control, double std_dev)
DLL_API void annDeallocPts(ANNpointArray &pa)
void annPlanted(ANNpointArray pa, int n, int dim, ANNpointArray src, int n_src, double std_dev)
void annClusEllipsoids(ANNpointArray pa, int n, int dim, int n_clus, ANNbool new_clust, double std_dev_small, double std_dev_lo, double std_dev_hi, int max_dim)
void annLaplacePts(ANNpointArray pa, int n, int dim)
void annGaussPts(ANNpointArray pa, int n, int dim, double std_dev)
void annCoGaussPts(ANNpointArray pa, int n, int dim, double correlation)
static int annRanInt(int n)
DLL_API ANNpointArray annAllocPts(int n, int dim)
void annUniformPts(ANNpointArray pa, int n, int dim)
static double annRanUnif(double lo, double hi)
void annCoLaplacePts(ANNpointArray pa, int n, int dim, double correlation)
void annClusOrthFlats(ANNpointArray pa, int n, int dim, int n_clus, ANNbool new_clust, double std_dev, int max_dim)
static void genGauss(ANNpointArray pa, int n, int dim, double *center, double *std_dev)