Set up simulation

Dear all
I want to replicate a prior research.
for U.S. firms, many of them are followed by financial analysts,

consider firm X that is followed by 3 analysts (A1, A2, A3).
firm Y that is followed by 4 analysts (A1, A2, B1, B2).

The authors use simulation identifying each firm's peer group. the simulation takes the number of analysts following firm x in year t and the number of other firms followed by each such analysts as inputs, in the simulation, these analysts following firm i then counterfactual choose the other firms they follow at random , from all New York Stock Exchange firms covered by analysts in year t. the simulation is repeated 1000 times. they set a criteria C for each firm is selected so that the probability of having more than C common analysts by chance is less than 1%. that is, C is set sufficiently large so as not to assign unrelated firms as peers.

I have data on which analysts cover which firm each year, but never done simulation, so not sure how to set up.

can someone help ?