#include #include #include #include #include #include void panic (char *str); int main (int argc, char* argv[] ) { // help if (argc < 3) { cout << "Info file format" << endl ; cout << "# of points in first gauss. # in second" << endl; cout << "dimensionality" << endl ; cout << "sigma_11 sigma_21 center_11 center_21" << endl; cout << "......." << endl ; cout << "sigma_1n sigma_2n center_1n center_2n" << endl; cout << "(first index refers to number of distribution, " << endl ; cout << "second - to that of coordinate)" << endl; panic ("gauss "); } // reading data, opening files ifstream infofile (argv[1]); ofstream outfile (argv[2]); int n1, n2, d; double c1[20], c2[20], sigma1[20], sigma2[20]; infofile >> n1 >> n2 >> d; for (int cnt=0 ; cnt < d ; cnt++) infofile >> sigma1[cnt] >> sigma2[cnt] >> c1[cnt] >> c2[cnt]; // -------------loop over points double coord[20]; double euclisum; // seeding rand int SEED; system ("date +%M%S > dummy") ; ifstream dum ("dummy" ) ; dum >> SEED; system ("rm dummy") ; srand (SEED); // ------------- NOISE for (int npts1 = 0 ; npts1 < n1 ; ) { euclisum=0; for (cnt = 0 ; cnt < d ; cnt++ ) { if ( sigma1[cnt] > 0 ) coord[cnt] = c1[cnt] + (rand())/4096.0; else coord[cnt] = c1[cnt] - (rand())/4096.0; euclisum -= (coord[cnt]-c1[cnt]) / sigma1[cnt] ; } if (rand()/40000.0 + 1/42000.0 < exp (euclisum)) { npts1++; for (cnt = 0 ; cnt < d ; cnt++ ) outfile << coord[cnt] << " " ; outfile << 0 << endl; } } // ++++++++++"SIGNAL" for (int cnt2 = 0 ; cnt2 < n2 ; ) { euclisum=0; for (cnt = 0 ; cnt < d ; cnt++ ) { if ( sigma2[cnt] > 0 ) coord[cnt] = c2[cnt] + (rand())/4096.0; else coord[cnt] = c2[cnt] - (rand())/4096.0; euclisum -= (coord[cnt]-c2[cnt]) / sigma2[cnt] ; } if (rand()/40000.0 + 1/42000.0 < exp (euclisum)) { cnt2++; for (cnt = 0 ; cnt < d ; cnt++ ) outfile << coord[cnt] << " " ; outfile << 1 << endl; } } } void panic (char *string) { cerr << string << endl; exit (0); }