Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41504

Re: Problem this random seed()

References <c447cffe-964f-4f8e-9931-0c3b5ff9bf6d@googlegroups.com> <be57c21d-7f3c-473b-b553-8a68b84331db@googlegroups.com> <mailman.3495.1363694370.2939.python-list@python.org> <a40ab4ab-a9cb-4a96-a4b6-d4eaa09dd8a4@googlegroups.com>
Date 2013-03-19 14:19 +0000
Subject Re: Problem this random seed()
From Sven <svenito@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3506.1363702753.2939.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 19 March 2013 13:50, NZach <nickzacharatos@gmail.com> wrote:

> Sorry, my previous reply was completely wrong. The time is initialized
> through the initialize() to 0. So, each time i call main() the simulation
> time is initialized to 0.
>
> I changed the code in order to print and check the values of
>
> G.Rnd.expovariate(MachineClass.SrvRate) and
> G.Rnd.expovariate(ArrivalClass.ArvRate)
>
> here is the code and the changes i made :
> http://codeviewer.org/view/code:30d8
>
> The values are not the same.
>
> The result i take is the following:
>
> Result from main() call No. 1 is 0.0452927906737
> Result from main() call No. 2 is 0.0588336669949
> 2
> First time Execution of Main Main
> [0.07267291894782457, 0.019146562687989536, 0.034780398625615376,
> 0.005528912370370478, 0.023636815811338075]
> [0.13472907136407936, 0.0025553071735785462, 0.08868344131130483,
> 0.05381286556098766, 0.044091180681591464]
> Second time Execution of Main
> [0.0335704752213292, 0.1321512230812724, 0.16025979406301488,
> 0.029210377271523574, 0.006680846943670858]
> [0.20642889529587374, 0.047894131266223446, 0.10958802111803392,
> 0.02393344456847461, 0.13280785022932287]
>

In the new code you are creating one instance of G which you seed with 1234
and then calling  expovariate on it each time you call main without
reseeding. You're only seeding it once and reusing it, so you would get
different values. What you had before, where you seeded G.Rnd in the main
was fine.

I also suggest you change one thing at a time, rather than reworking large
parts each iteration. All I was suggesting was a simple print statement in
the Run method like you had it before


-- 
./Sven

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-18 18:57 -0700
  Re: Problem this random seed() eli m <techgeek201@gmail.com> - 2013-03-18 19:36 -0700
  Re: Problem this random seed() alex23 <wuwei23@gmail.com> - 2013-03-18 19:51 -0700
    Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 03:52 -0700
  Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 03:54 -0700
    Re: Problem this random seed() Sven <svenito@gmail.com> - 2013-03-19 11:59 +0000
      Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 05:27 -0700
      Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 05:27 -0700
      Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 06:50 -0700
        Re: Problem this random seed() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-19 14:18 +0000
        Re: Problem this random seed() Sven <svenito@gmail.com> - 2013-03-19 14:19 +0000
          Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 07:44 -0700
            Re: Problem this random seed() Sven <svenito@gmail.com> - 2013-03-19 15:05 +0000
            Re: Problem this random seed() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-19 15:09 +0000
              Re: Problem this random seed() Sven <svenito@gmail.com> - 2013-03-19 15:19 +0000
          Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 07:44 -0700
      Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 06:50 -0700
  Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 07:18 -0700
  Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 08:23 -0700
    Re: Problem this random seed() NZach <nickzacharatos@gmail.com> - 2013-03-19 08:26 -0700

csiph-web