F
Francogrex
Hi, I'm trying to sample without replacement some numbers (xons:70
values out of 1 to 200 and xEPS1cover:150 values out of 1 to 200).
Then I'm trying to intersect both samples to see how many are in
common. I have tried to write the code below, but I cannot seem to
sample without replacement (there are recurrent numbers within the
same sample, I don't want that) and I cannot either find the exact
intersection between the two samples. Can anyone please help or give
some hints. Thanks
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream osdis("dis.txt");
ofstream oscover("cover.txt");
srand(10);
int Ntot=200;
int Nons=70;
int i=0,j=0,r=0,t=0;
int xtot[200];
int xons[Ntot];
for (int i = 0; i < Ntot; i++){
xtot = i;
}
for (int i = 0; i < Nons; i++) {
r = rand()%Ntot + 0;
t = xtot[r];
xtot[r] = xtot;
xons = t;
}
int NEPS1cover=150;
int xEPS1cover[NEPS1cover];
for (int i = 0; i < NEPS1cover; i++) {
r = rand()%Ntot + 0;
t = xtot[r];
xtot[r] = xtot;
xEPS1cover = t;
}
int R=0,u=0;
int xEPS1expected[NEPS1cover];
while(u<Nons){
int v=0;
while (v<NEPS1cover){
cout<<"dis: "<<xons<<"\n";
cout<<"cover: "<<xEPS1cover[v]<<"\n";
if (xons==xEPS1cover[v]){
printf("YES\n");
R=R+1;
}
v=v+1;
}
u=u+1;
}
for (j=0;j<Nons;j++) osdis<<xons[j]<<"\n";
for (i=0;i<NEPS1cover;i++) oscover<<xEPS1cover<<"\n";
cout<<"R :"<<R<<"\n";
system("PAUSE");
return 0;
}
values out of 1 to 200 and xEPS1cover:150 values out of 1 to 200).
Then I'm trying to intersect both samples to see how many are in
common. I have tried to write the code below, but I cannot seem to
sample without replacement (there are recurrent numbers within the
same sample, I don't want that) and I cannot either find the exact
intersection between the two samples. Can anyone please help or give
some hints. Thanks
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream osdis("dis.txt");
ofstream oscover("cover.txt");
srand(10);
int Ntot=200;
int Nons=70;
int i=0,j=0,r=0,t=0;
int xtot[200];
int xons[Ntot];
for (int i = 0; i < Ntot; i++){
xtot = i;
}
for (int i = 0; i < Nons; i++) {
r = rand()%Ntot + 0;
t = xtot[r];
xtot[r] = xtot;
xons = t;
}
int NEPS1cover=150;
int xEPS1cover[NEPS1cover];
for (int i = 0; i < NEPS1cover; i++) {
r = rand()%Ntot + 0;
t = xtot[r];
xtot[r] = xtot;
xEPS1cover = t;
}
int R=0,u=0;
int xEPS1expected[NEPS1cover];
while(u<Nons){
int v=0;
while (v<NEPS1cover){
cout<<"dis: "<<xons<<"\n";
cout<<"cover: "<<xEPS1cover[v]<<"\n";
if (xons==xEPS1cover[v]){
printf("YES\n");
R=R+1;
}
v=v+1;
}
u=u+1;
}
for (j=0;j<Nons;j++) osdis<<xons[j]<<"\n";
for (i=0;i<NEPS1cover;i++) oscover<<xEPS1cover<<"\n";
cout<<"R :"<<R<<"\n";
system("PAUSE");
return 0;
}