Loading ...
Sorry, an error occurred while loading the content.

Re: what means random 10 + 5

Expand Messages
  • sifu_008
    random 10 + 1 is the same as 1 + random 10 now random 10 generates integers between 0 and 9...... therefore 1 + random 10 adds 1 to the number generated by
    Message 1 of 7 , May 31, 2011
    • 0 Attachment
      random 10 + 1 is the same as 1 + random 10
      now random 10 generates integers between 0 and 9...... therefore 1 + random 10 adds 1 to the number generated by random 10 i.e. (1 + random 10) generates integer between 1 and 10.

      For the code snippet
      repeat random 10 + 1 [set savoir-faire fput random 10 savoir-faire]

      the code within the [] (square bracket) is repeated random 10 + 1 times i.e. the code snippet is repeated some random times (which is between 1 and 10).

      The reason for adding 1 with random 10 .....is if you do not add 1, then the code in the square bracket would be repeated any time between 0 and 9...... the problem is with the lower boundary.....if the random number generates a 0......then that piece of the code will not be executed at all.....in order to make sure that the code is executed at least once ...... a 1 needed to be added.

      Hope that helps
      Sifat Momen

      --- In netlogo-users@yahoogroups.com, anuar jaafar <anuarjaafar85@...> wrote:
      >
      > My opinion is, random 15 is not equal with random 10 + 5
      > the different is, random 15 is the number is taking randomly between 0 to 14 while random 10 + 5, the number is taking randomly between 5 to 14. 
      >
      > thank you...
      >
      >
      >
      > ________________________________
      > From: Simone Gabbriellini <simone.gabbriellini@...>
      > To: netlogo-users@yahoogroups.com
      > Sent: Monday, May 30, 2011 4:01 PM
      > Subject: Re: [netlogo-users] what means random 10 + 5
      >
      >
      >  
      > as far as I understand it, random 10 + 1 means that you add 1 to a random number chosen in the interval 0 - 9.
      > Instead, if you write random (10+1) than you mean random 11.
      >
      > HTH,
      > simone
      >
      > Il giorno 29/mag/2011, alle ore 00.00, debutante ha scritto:
      >
      > >
      > > hi
      > >
      > > please what does the statement that is bold
      > >
      > > to initi-variable-agent
      > > set savoir-faire []
      > > set role-assume []
      > > set deja-choisit false
      > > repeat random 10 + 1 [set savoir-faire fput random 10 savoir-faire]
      > > set savoir-faire remove-duplicates savoir-faire
      > >
      > > end
      > >
      > >
      > > thank you
      > > --
      > > View this message in context: http://old.nabble.com/what-means-random-10-%2B-5-tp31725327p31725327.html
      > > Sent from the NetLogo-Users mailing list archive at Nabble.com.
      > >
      > >
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.