[Tutor] Structure of my simulation / monte-carlo
Kent Johnson
kent37 at tds.net
Mon Nov 2 03:22:31 CET 2009
On Sun, Nov 1, 2009 at 8:34 PM, Dave Angel <davea at ieee.org> wrote:
> I mostly agree with Kent, but I apparently disagree about which classes are
> actually needed. Think what things will have actual instances that will
> last long enough to be worth formally defining. So you need Applicant, and
> Institution, and Simulation. Notice they're all singular. I'm assuming one
> simulation is a single set of test data, with its results. Then you create
> as many instances of Simulation as you need for comparison purposes, and
> perhaps keep a list of them. It's not clear that list needs any further
> structure than the built-in list type provides.
That's pretty much what I have been suggesting. I think you may be
disagreeing with Vincent's interpretation of my suggestion :-) It
might be worth having a results class for the simulation to hold the
code that computes statistics on the results. I think it's probably
worth having a class to run the multiple simulations but that may just
be a function.
> You don't need a class for creating an Applicant, that's just a line or two
> in a loop in the Simulation class. Similarly for Institution.
Right.
>
> And if I understand it correctly, you don't need very many different methods
> in Simulation either. You need the __init__ to save enough information to
> "tag" this particular simulation (call it a label, it's probably just a
> string). If __init__ is too complex, you may want to break it into several
> phases. But they'll always be called in direct succession, so there may not
> be any point. Then you need something that triggers an analysis, and
> something that queries for particular results. That last will then be
> called from plotting or charting routines.
Kent.
More information about the Tutor
mailing list