文字化けが怖いのでブログに保存
等確率で出るカードがY種類あった時にn回引いて全種類そろう確率。
[0回]
#data of 4 types
0 0.0000000
1 0.0000000
2 0.0000000
3 0.0000000
4 0.0937300
5 0.2314500
6 0.3799700
7 0.5115600
8 0.6209900
9 0.7120600
10 0.7796700
11 0.8335400
12 0.8751800
13 0.9044400
14 0.9301800
15 0.9472500
16 0.9594800
17 0.9699900
18 0.9763700
19 0.9837300
20 0.9869300
21 0.9906200
22 0.9928700
23 0.9947800
24 0.9957400
25 0.9969700
26 0.9977500
27 0.9981300
28 0.9987000
29 0.9988000
30 0.9992500
31 0.9995600
32 0.9995300
33 0.9996400
34 0.9998100
35 0.9998700
36 0.9998400
37 0.9998900
38 0.9999000
39 0.9999800
40 0.9999900
41 0.9999900
42 0.9999500
43 0.9999900
44 1.0000000
45 1.0000000
46 1.0000000
47 0.9999900
48 1.0000000
49 1.0000000
50 0.9999800
51 1.0000000
52 1.0000000
53 1.0000000
54 1.0000000
55 1.0000000
56 1.0000000
57 1.0000000
58 1.0000000
59 1.0000000
60 1.0000000
61 1.0000000
62 1.0000000
63 1.0000000
64 1.0000000
65 1.0000000
66 1.0000000
67 1.0000000
68 1.0000000
69 1.0000000
70 1.0000000
71 1.0000000
72 1.0000000
73 1.0000000
74 1.0000000
75 1.0000000
76 1.0000000
77 1.0000000
78 1.0000000
79 1.0000000
80 1.0000000
81 1.0000000
82 1.0000000
83 1.0000000
84 1.0000000
85 1.0000000
86 1.0000000
87 1.0000000
88 1.0000000
89 1.0000000
90 1.0000000
91 1.0000000
92 1.0000000
93 1.0000000
94 1.0000000
95 1.0000000
96 1.0000000
97 1.0000000
98 1.0000000
99 1.0000000
#data of 7 types
0 0.0000000
1 0.0000000
2 0.0000000
3 0.0000000
4 0.0000000
5 0.0000000
6 0.0000000
7 0.0063300
8 0.0243900
9 0.0574900
10 0.1061900
11 0.1633800
12 0.2280500
13 0.2955700
14 0.3679800
15 0.4355500
16 0.4996200
17 0.5577100
18 0.6112800
19 0.6611600
20 0.7032900
21 0.7415000
22 0.7755700
23 0.8079000
24 0.8343400
25 0.8550700
26 0.8746600
27 0.8932000
28 0.9084500
29 0.9211100
30 0.9330700
31 0.9412000
32 0.9488900
33 0.9574300
34 0.9629700
35 0.9680400
36 0.9727000
37 0.9764900
38 0.9805700
39 0.9820700
40 0.9853900
41 0.9874800
42 0.9886000
43 0.9904800
44 0.9917700
45 0.9934200
46 0.9938500
47 0.9949700
48 0.9957800
49 0.9964000
50 0.9967100
51 0.9974000
52 0.9976900
53 0.9981300
54 0.9983200
55 0.9985800
56 0.9987100
57 0.9988500
58 0.9991700
59 0.9991400
60 0.9992000
61 0.9994300
62 0.9994400
63 0.9996000
64 0.9996500
65 0.9997000
66 0.9997400
67 0.9998200
68 0.9998000
69 0.9997900
70 0.9998800
71 0.9999000
72 0.9999300
73 0.9999400
74 0.9999200
75 0.9999200
76 0.9999000
77 0.9999800
78 0.9999700
79 0.9999700
80 0.9999600
81 0.9999700
82 0.9999700
83 0.9999700
84 0.9999900
85 1.0000000
86 1.0000000
87 0.9999800
88 0.9999900
89 1.0000000
90 0.9999800
91 1.0000000
92 0.9999900
93 0.9999900
94 1.0000000
95 1.0000000
96 1.0000000
97 0.9999900
98 1.0000000
99 1.0000000
#data of 10 types
0 0.0000000
1 0.0000000
2 0.0000000
3 0.0000000
4 0.0000000
5 0.0000000
6 0.0000000
7 0.0000000
8 0.0000000
9 0.0000000
10 0.0004600
11 0.0017800
12 0.0062200
13 0.0147700
14 0.0264600
15 0.0467500
16 0.0723500
17 0.0993900
18 0.1346900
19 0.1727700
20 0.2137300
21 0.2594900
22 0.3028800
23 0.3498300
24 0.3934900
25 0.4368700
26 0.4808500
27 0.5176400
28 0.5581100
29 0.5935700
30 0.6273500
31 0.6581500
32 0.6933000
33 0.7189400
34 0.7423900
35 0.7655500
36 0.7879900
37 0.8065100
38 0.8260800
39 0.8416700
40 0.8583900
41 0.8724000
42 0.8838100
43 0.8961000
44 0.9042700
45 0.9147900
46 0.9238700
47 0.9297000
48 0.9380500
49 0.9437300
50 0.9485500
51 0.9541000
52 0.9583500
53 0.9632700
54 0.9671800
55 0.9703500
56 0.9735300
57 0.9761300
58 0.9776700
59 0.9803500
60 0.9819600
61 0.9828700
62 0.9857500
63 0.9869400
64 0.9882100
65 0.9888800
66 0.9909200
67 0.9912100
68 0.9919100
69 0.9931200
70 0.9940100
71 0.9944100
72 0.9948000
73 0.9952300
74 0.9959900
75 0.9965000
76 0.9967600
77 0.9970200
78 0.9971100
79 0.9975200
80 0.9977200
81 0.9979900
82 0.9984100
83 0.9984000
84 0.9985700
85 0.9985500
86 0.9989000
87 0.9989600
88 0.9990500
89 0.9992300
90 0.9992200
91 0.9993500
92 0.9994500
93 0.9995100
94 0.9995200
95 0.9995600
96 0.9996400
97 0.9995900
98 0.9996200
99 0.9998000
#data of 20 types
0 0.0000000
1 0.0000000
2 0.0000000
3 0.0000000
4 0.0000000
5 0.0000000
6 0.0000000
7 0.0000000
8 0.0000000
9 0.0000000
10 0.0000000
11 0.0000000
12 0.0000000
13 0.0000000
14 0.0000000
15 0.0000000
16 0.0000000
17 0.0000000
18 0.0000000
19 0.0000000
20 0.0000000
21 0.0000000
22 0.0000000
23 0.0000100
24 0.0000100
25 0.0000200
26 0.0000800
27 0.0002100
28 0.0004500
29 0.0007900
30 0.0012100
31 0.0020200
32 0.0033900
33 0.0050000
34 0.0069000
35 0.0090900
36 0.0133700
37 0.0174000
38 0.0225700
39 0.0293000
40 0.0353600
41 0.0448500
42 0.0540700
43 0.0637300
44 0.0752200
45 0.0862500
46 0.1012900
47 0.1136400
48 0.1321400
49 0.1459100
50 0.1639400
51 0.1821500
52 0.2016300
53 0.2204300
54 0.2385000
55 0.2575000
56 0.2812100
57 0.2987900
58 0.3182900
59 0.3408100
60 0.3605700
61 0.3804600
62 0.4008500
63 0.4218900
64 0.4436300
65 0.4604400
66 0.4795600
67 0.4994800
68 0.5214200
69 0.5383400
70 0.5545600
71 0.5736300
72 0.5885900
73 0.6057100
74 0.6236700
75 0.6380700
76 0.6522000
77 0.6693100
78 0.6820500
79 0.6948200
80 0.7101300
81 0.7190900
82 0.7336900
83 0.7420400
84 0.7539900
85 0.7681100
86 0.7793700
87 0.7898000
88 0.7969900
89 0.8070600
90 0.8173700
91 0.8240600
92 0.8342300
93 0.8409100
94 0.8480600
95 0.8535100
96 0.8606200
97 0.8701900
98 0.8727700
99 0.8799800
#include <stdio.h>
#include<stdlib.h>
#include<time.h>
void comp(int Y){
printf("#data of %d types\n",Y);
int n,t,i,j,k,try=100000;
int miss=0;
srand((unsigned)time(NULL));
for(k=0;k<100;k++){
n=k;
miss=0;
int comp[Y];
for(j=0;j<try;j++){
for(i=0;i<Y;i++)
comp[i]=0;
for(i=0;i<n;i++)
comp[rand()%Y]=1;
for(i=0;i<Y;i++){
if(comp[i]==0){miss++;break;}
}
}
printf("%3d %1.7lf\n",k,1.0-((double)miss/(double)try));
}
}
main(){
comp(4);
comp(7);
comp(10);
comp(20);
}
PR