Coupon Problem With Multiplicities

timetoall[c_,multiplicities_,num_] := Module[{},
soln = {};
For[n = 1, n ≤ num, n++,
{
For[i = 0, i ≤ c+1, i++, value[i] = 0];
j = 0;
sum = 0;
While[sum < multiplicities * c,
{
z = RandomInteger[c-1]+1;
j = j+1;
If[value[z] < multiplicities, value[z] = value[z]+1];
sum = Sum[value[i], {i,1,c}];
}];
soln = AppendTo[soln,j];
}];
Print[Histogram[soln,Automatic, "Probability"]];
Print["Analysis for: c = ", c, ", multiplicities = ", multiplicities, ", and iterations = ", num, "."];
Print["Mean value: ",1.0 Mean[1.0 soln]];
Print["Std Deviation: ", 1.0 Sqrt[1.0 Variance[soln]]];
Print["Normalized mean value: ",1.0 Mean[1.0 soln] / (c Sum[1/k,{k,1,c}])];
Print["Normalized Std Deviation: ", 1.0 Sqrt[1.0 Variance[soln]] / (c Sum[1/k,{k,1,c}])^2];
];

timetoall[100,2,100]

?Harmonic

timetoallrange[cstart_,cend_,multiplicities_,num_] := Module[{},
cdata = {};
normalizedcdata = {};
For[c = cstart, c ≤ cend,c = c + 2,
{
soln = {};
For[n = 1, n ≤ num, n++,
{
For[i = 0, i ≤ c+1, i++, value[i] = 0];
j = 0;
sum = 0;
While[sum < multiplicities * c,
{
z = RandomInteger[c-1]+1;
j = j+1;
If[value[z] < multiplicities, value[z] = value[z]+1];
sum = Sum[value[i], {i,1,c}];
}]; (* end while loop *)
soln = AppendTo[soln,j];
}]; (* end n loop *)
cdata = AppendTo[cdata, {c,1.0 Mean[1.0 soln]}];
normalizedcdata = AppendTo[normalizedcdata, {c, 1.0 Mean[1.0 soln] /  (c Sum[1/k, {k,1,c}])}];
(*Print[Histogram[soln,Automatic, "Probability"]];
Print["Mean value: ",1.0 Mean[1.0 soln]];
Print["Std Deviation: ", 1.0 Sqrt[1.0 Variance[soln]]];*)
}]; (* end c loop *)
Print[ListPlot[cdata]];
Print[ListPlot[normalizedcdata]];
];

timetoallrange[20,200,2,100]

timetoall[300,2,100]
timetoall[400,2,100]
timetoall[500,2,100]
timetoall[1000,2,100]

timetoall[1000,2,1000]

timetoall[1000,1,10]

couponalt[num_] := Module[{},
soln = {};
For[n = 1, n ≤ num, n++,
{
done1 = 0;
done2 = 0;
count = 0;
While[done1 ≤ 1 || done2 ≤ 1,
{
count = count+1;
If[Random[] < .5, done1 = done1+1];
If[Random[] < .5, done2 = done2+1];
}]; (* end of while loop *)
soln = AppendTo[soln, count];
If[Mod[n,num/10] == 0,
{
Print["Doing case of getting two of each, can draw either each time, iterations = ", num];
Print["At n = ", n];
Print["Mean is ", Mean[soln] 1.0];
Print["StDev is ", Sqrt[Variance[soln] 1.0]];
Print[" "];
}]; (* end of if statement *)
}]; (* end of n loop *)
Print["Doing case of getting two of each, can draw either each time, iterations = ", num];
Print["Mean is ", Mean[soln] 1.0];
Print["StDev is ", Sqrt[Variance[soln] 1.0]];
];

couponalt[100000]

couponalt[1000000]