[Tutor] Structure of my simulation / monte-carlo

Vincent Davis vincent at vincentdavis.net
Sat Oct 31 17:54:44 CET 2009

I ask this question in part because of a fee remarks from another question I
ask "class attribute to initiate more classes"

Basically I am simulation the process of applicants to schools and trying to
ask/answer some questions like "what conditions do you need to have an
optimal solution" Oh and to learn python. I basically had it working as a
script rather than using a class structure but it was very inflexible and I
still needed to learn about classes.

What I have these classes
class Applicant: has lots of attributes (self.gpa = random.gauss(50, 10)
about the Applicant and def() defining how/why an applicant applies to an

class Institution: Lots of attributes (self.quality = random.gauss(50,
10)) about the Institution and def() defining how the institution considers
the applicant.

class Match: this defines the interaction of the population of Applicants
and Institutions, i.e. the rules of the game and returns the outcome i.e.
which Applicants went to which Institutions.

As of now I have been running 1 Match at a time. Which is to say generate
8000 instances of Applicant and 300 instances of Institution and then run
the match Match(app_list, inst_list) and I do this with a short script.

So now I need to implement my monte-carlo. By that I mean that i want to set
some of the initial condition such as GPA, and Quality and basically re-run
the what I descried above, (generate applicant, institutions, match them)
 Then save the results.

So my plan way to make a new class. This class would define the Applicant
characteristics "self.gpa = random.gauss(mean, SD)" and the
institutions self.quality = random.gauss(mean, sd)

so it would look something like this

class RepeatMatch:
    def __int__(self, app_mean, app_sd, inst_mean, inst_sd, match_ repeat)
        self.app_mean = app_mean
        self.match_repeat = match_repeat

   def makeApplicants():

   def makeInstitutions():

   def runMatches(self)
   # runs the match match_repeat number of times, saves results

# then I calculate some characteristics of the results

    def ratio_dist():
         # returns the Mean and sd of GPA/Quality

Does it make sense to do it this way? Is there a better/alternative way of
thinking about this. In the end I want to compare the results of repeated
simulations "RepeatMatch(50,2….) Compared to RepeatMatch(50,15….)"
This is way I had ask the earlier question "class attribute to initiate more

Vincent Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091031/cb9c6e41/attachment-0001.htm>

More information about the Tutor mailing list