Search Options
close
Search the following clips:
All Clips
Everyone's Clips
My Guides
Sign Up
Install
Learn More
Login
Random Numbers in a Range Using Generic Programming
prostoalex
follow
0
3-23-2008 2:39 AM
135 views
Add a Comment
Login
to Comment. Not a member yet?
Sign up
Related Clips
Army survival Guide
is the situation much worse than they are ...
The "Great Wall Street Heist" of 2008
TRUE: Obama sounded the alarm on subprimes
New BBC Series on America
Another "Pants on Fire" for McCain
Troopergate Report: Palin "Unlawfully Abus...
More clips from
prostoalex
The Complete Guide for You to Become an Al...
Git Magic
The Art of Engineering
Today's Top Clips
Jews Protect Palestinians in Harvest of Hate
ACLU: Bush Tried to Create 'Gitmo Inside the US'
Even When You Sleep, Your Brain Is Awake
A "Christian" Cure for Homosexuality
Citizen Terrorists Deleted
I'll Take Hope Over Fear and Loathing, Thank You Very Much
DNA could reveal your surname
Rednecks for Obama
Holographic television to become reality
Country First? Really?
visit the
Top Clips page
View the Top Clips from
March 23, 2008
Embed This Clip In Your Site...
<div style="margin: 12px 0px; font-family: arial; color: #333333; background: #ffffff; border: solid 4px #e5e5e5; width: 100%; clear: left;"><div class="CM_CTB_Content_Wrap" style="margin: 0px; padding: 0px;background-color: #ffffff;"><div style="border-bottom: solid 1px #dcdcdc; white-space: nowrap; margin-bottom: 8px; background-color: #eeeeee ;background-image: url(http://clipmarks.com/images/source-bg.gif); background-repeat: repeat-x; height: 24px; line-height: 24px; vertical-align: middle; padding-bottom: 4px; color: #666666; font-size: 10px;" ><a href="http://clipmarks.com/clip-to-blog/" title="see clips that are hot right now"><img src="http://content.clipmarks.com/blog_embed/ce39c263-135f-4582-b0c2-84499a20767a/4B8A33CB-406A-42CE-807E-A854DDC9372F/" alt="" width="19" height="19" border="0" style="vertical-align: middle; margin: 0px 4px; display: inline; border: none; float:none;" /></a>clipped from <a title="http://www.ddj.com/article/printableArticle.jhtml?articleID=206904716&dept_url=/cpp/" href="http://www.ddj.com/article/printableArticle.jhtml?articleID=206904716&dept_url=/cpp/" style="font-size: 11px;">www.ddj.com</a></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.ddj.com/article/printableArticle.jhtml?articleID=206904716&dept_url=/cpp/"><P> Consider the generation of random numbers in an interval, say the generation of an integer in {0,1,...,m-1} where the probability of each integer is 1/m. Usually, you have a source of randomness that provides random bits in chunks of architecture word size—something like the wrapper around the mtrand library (bedaux.net/mtrand); see Listing One.</P></blockquote><div style="height: 2px; font-size: 2px; background: #dcdcdc; border-bottom: solid 1px #f5f5f5; margin: 2px 4px;"></div><blockquote style="text-align: left; padding: 0px 8px; margin: 4px 0px 8px 0px; background: transparent; border: none;" cite="http://www.ddj.com/article/printableArticle.jhtml?articleID=206904716&dept_url=/cpp/"><P> Mtrand implements the Mersenne Twister random-number generator (<A href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html">www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html</A>), which is a high-quality source of randomness. By "high quality," I mean that you don't need to consider low-order bits of words produced by the generator to be of inferior quality than high-order bits. In principle, you can take the value returned by <I>next()</I> <I>modulo</I> <I>m</I> to produce an integer in the range [<I>0,m-1</I>]. </P></blockquote></div><div style="margin: 0px 6px 6px 4px;"><table style="font-size: 11px;border-spacing: 0px;padding: 0px;" cellpadding="0" cellspacing="0" width="100%"><tr><td style="background:transparent;border-width:0px;padding:0px;"> </td><td align="right" style="background:transparent;border-width:0px;padding:0px;width:107px" width="107"><a href="http://clipmarks.com/share/4B8A33CB-406A-42CE-807E-A854DDC9372F/blog/" title="blog or email this clip"><img src="http://content8.clipmarks.com/images/c2b-foot.png" border="0" alt="blog it" width="107" height="17" style="border-width:0px;padding:0px;margin:0px;" /></a></td></tr></table></div></div>
Clipmarks
Home
New Clips
Top Clips
Dashboard
Popular Topics
News
Life
Science
Technology
Entertainment
Get Started
Sign Up
Install Clipping Tool
How Clipping Works
Clip-to-Blog™
ClipSearch
Tools and Resources
FAQ
ClipWeek
Top Clippers
Top Tags
Site Map
About Clipmarks
About Us
Contact
Blog
Copyright
Privacy
EULA
OK