• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 8 Digit random number
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 8 Digit random number


  • Subject: Re: 8 Digit random number
  • From: "Mr. Gecko" <email@hidden>
  • Date: Thu, 8 May 2008 08:27:42 -0500

Yeah I knew that before in the days that I made c programs but it been so long that I forgot.

On May 8, 2008, at 6:57 AM, Gregory Weston wrote:

Since neither the question nor the answer is particularly Cocoa- related, I'm following up off-list. I just wanted to make sure that you understood that using % to scale your raw result into the range you want messes with the uniformity of the sequence. Consider, as a degenerate case, that you had a random number generator that gave you back a number from 0 to 15 and you wanted a number between 0 and 11. If you did RND % 12, 0-3 will show up twice as often as any other result. The closer the range of the random function is to an integer multiple of the range you actually want, the less absolute impact that has but there will almost always be some skewing introduced. To alleviate that, you want to scale the raw result to a number in [0,1), multiply that by the range of your desired result and then add your minimum.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: How to send email without using email client
  • Next by Date: Re: Quadratic curves in NSBezierPath
  • Previous by thread: Re: 8 Digit random number
  • Next by thread: Re: Getting an array/tree controller to select newly added managed objects
  • Index(es):
    • Date
    • Thread