You can also think to the problem as the following: Consider Monte Carlo insertion/deletion and moves in a big sphere, where the small spheres represent atoms of different sizes (r1 and r2) in your case which interact with hard sphere potential (since the spheres do not overlap.) So each Monte Carlo trial includes displacement of one of the inserted spheres followed by an insertion/deletion attempt of another sphere with randomly chosen size between r1 and r2. And you will see, that this will depend on another parameter, known as `chemical potential', which will determine number of small spheres filling the big sphere.
thanks for the code. by choosing a random diagonal, the spheres are aligned on a line but that is not what i want . i want the the spheres to be distributed randomly in the bigger sphere without any overlap
What exactly do you mean by “randomly fill”? Do you just want to put a few little spheres into a spherical container (a), or do you want to create a random close packing in the container (b)?
(a) Follow Joachim's advice: place the spheres at random locations with the container; if there is an overlap, cancel the insertion and try another location.
(b) Try a kind of Monte Carlo technique: Place your spheres into a very large container, using technique (a); then shift spheres randomly and slowly shrink the container as far as possible. This corresponds approximately to performing an NpT Monte Carlo simulation on a hard-sphere mixture, so you might borrow and modify MC code for that.