• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
rAm_y_

Pi decimals as a random number generator

14 posts in this topic

Not sure if there's anything in this but I know random number generators are a sought after thing in programming.

 

So Pi can be described by the Taylor series 4* (1 - 1/3 + 1/5 - 1/7 + 1/9...)

 

however nobody has ever been able to find any order in the decimal representation that is produced, some think it's truely a random number, is there anyway to use this as a random number generator?

0

Share this post


Link to post
Share on other sites
Hello rAm_y,

It also depends on the accuracy of your simulation. If you just need a number to get an index into something, for example some bonus item, then speed is more important. Look into XorShift.
0

Share this post


Link to post
Share on other sites

No, the digits of pi are not random. They can be generated using a very short program, and that's the very definition of non-random.

 

If, by "not random" you mean the same sequence would be generated each time, I would agree. If you really mean to say that the digits of pi are not random, mathematicians at Purdue, Berkeley, and elsewhere appear to have concluded, at best, that pi's randomness is an open question. I can find no reference that indicates that (in the sequence of digits of pi) the digit following any finite sequence can be predicted, which is one indication of randomness.

 

With regard to the OP:


is there anyway to use this as a random number generator?

 

If you need to generate a number that cannot be predicted before it's generated (perhaps the intent of Alvaro's statement), that's problematic.

 

For instance, assuming that the digits of pi are random (as mentioned above, there are questions in that regard,) you would have to develop an algorithm to randomly select a sequence from those digits. Therein lies the rub. A random selection algorithm such as that would either be predictable or would need yet another such supporting algorithm.

0

Share this post


Link to post
Share on other sites
The only precise notion of randomness I am familiar with is Kolmogorov randomness. Under that definition, a string is considered random if it is shorter than any program that can generate it. A sufficiently long string of digits from pi will certainly be longer than a program that generates it, and therefore it is not random.

Of course, by this definition, the output of a pseudo-random number generator is never random. The article from Purdue seems to be concerned with whether the digits of Pi pass something like the Diehard tests. The article from Berkeley talks about the quest to prove pi is normal in some base. Those might be interesting research questions but, even if the answers were affirmative, it would make very little sense to use digits of pi as pseudo-random numbers. There are much cheaper ways to generate high-quality pseudo-random numbers.
0

Share this post


Link to post
Share on other sites

No, the digits of pi are not random. They can be generated using a very short program, and that's the very definition of non-random.

 

Technically, pseudo random generators aren't really random according to those criterias either.  They too, are generated using a very short program, and their progression is determined as long as you have the seed, which in a lot of random number generators can be set to any value you want.

 

Another issue with random number generators is distribution of numbers.  Some generators slightly favours the numbers near to zero, for instance.  That is because of the use of the modulus operator that is often used together with random number generators (modulus bias), or because of the algorithm itself.

 

That is one of the reasons you have more modern random number generators that takes this into consideration, like the arc4random_uniform() you find on the OS X platform, for instance, that is made to avoid this modulus bias.

0

Share this post


Link to post
Share on other sites

Completely off-topic, but this thread is reminding me of pifs (Pi as a file storage mechanism).

 

Given that you can actually find every sequence of bytes in PI no matter how long, which I doubt, (you can't find PI inside PI, for instance, since it is a transcendental number, and if you could, you would actually have an irrational number, which is algebraic numbers) I wonder the amount of metadata you would have to write down to "store your file in PI". biggrin.png

Edited by aregee
0

Share this post


Link to post
Share on other sites


Given that you can actually find every sequence of bytes in PI no matter how long, which I doubt, (you can't find PI inside PI, for instance, since it is a transcendental number, and if you could, you would actually have an irrational number, which is algebraic numbers) I wonder the amount of metadata you would have to write down to "store your file in PI".

 

Yes, that is the joke, the metadata must be at least as large as the data itself, as expected from a simple pigeonhole argument (but some people still believe you can get something for nothing, which makes for some hilarious bug reports/issues) smile.png

2

Share this post


Link to post
Share on other sites

Yes, that is the joke, the metadata must be at least as large as the data itself, as expected from a simple pigeonhole argument (but some people still believe you can get something for nothing, which makes for some hilarious bug reports/issues) smile.png

 

 

I was refreshing my weak knowledge on Huffman coding, since I am making a MP3 decoder just for "fun", and stumbled upon this quote that made me think about your mention of the pigeonhole principle in this regards:

 

"In general, data cannot be compressed. For example, we cannot losslessly represent all m-bit strings using (m ? 1)-bit strings, since there are 2(pow)m possible m-bit strings and only 2(pow)m?1 possible (m?1)-bit strings."

 

This is out of context though, if it sounds weird that "In general, data cannot be compressed".  Here is the link to get the context: 

 

http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2012/lecture-notes/MIT6_046JS12_lec19.pdf

Edited by aregee
2

Share this post


Link to post
Share on other sites

Yes, that is the joke, the metadata must be at least as large as the data itself, as expected from a simple pigeonhole argument (but some people still believe you can get something for nothing, which makes for some hilarious bug reports/issues) smile.png

 
I was refreshing my weak knowledge on Huffman coding, since I am making a MP3 decoder just for "fun", and stumbled upon this quote that made me think about your mention of the pigeonhole principle in this regards:
 
"In general, data cannot be compressed. For example, we cannot losslessly represent all m-bit strings using (m ? 1)-bit strings, since there are 2(pow)m possible m-bit strings and only 2(pow)m?1 possible (m?1)-bit strings."
 
This is out of context though, if it sounds weird that "In general, data cannot be compressed".  Here is the link to get the context: 
 
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-design-and-analysis-of-algorithms-spring-2012/lecture-notes/MIT6_046JS12_lec19.pdf


That is correct. All that lossless compression schemes do is look at the input to discover that some patterns are more likely than others, and then process the data such that these common patterns map to a shorter representation while less common patterns map to a (necessarily) longer representation. They feed on redundancy in the input, and operate on the assumption that stuff that human beings like to use, like text files and music, are not just white noise but have structure to them. In some abstract sense, their goal is to extract information from data. If you feed any lossless compression scheme a stream of uniformly random bits, it will never, ever succeed in compressing it on average, as it should be. This mirrors the laws of thermodynamics, which is not surprising given that thermodynamics deal with disorder and structure, which is very much what information is (in fact, this is why information content is also called entropy).

Lossy compression schemes, on the other hand, simply trade correctness for efficiency, so that you can get better compression if you don't need 100% of the data intact. This is often the case when dealing with perceptual media like pictures and audio, because our brains have some rather powerful built-in error-correction features, but is typically unacceptable when it comes to structured data like source code or even simple text (we can also correct mangled text to some extent, but it's much more work and still relies on context being present, as usual).

I know that there is a very old gamedev.net thread where the thread author claims he's come up with a lossless compression scheme which always shortens its input. It's a fun read if you are interested in the subject. Here, I dug it out for you: clicky. Edited by Bacterius
0

Share this post


Link to post
Share on other sites

That is correct. All that lossless compression schemes do is look at the input to discover that some patterns are more likely than others, and then process the data such that these common patterns map to a shorter representation while less common patterns map to a (necessarily) longer representation. They feed on redundancy in the input, and operate on the assumption that stuff that human beings like to use, like text files and music, are not just white noise but have structure to them. In some abstract sense, their goal is to extract information from data. If you feed any lossless compression scheme a stream of uniformly random bits, it will never, ever succeed in compressing it on average, as it should be. This mirrors the laws of thermodynamics, which is not surprising given that thermodynamics deal with disorder and structure, which is very much what information is (in fact, this is why information content is also called entropy).


Lossy compression schemes, on the other hand, simply trade correctness for efficiency, so that you can get better compression if you don't need 100% of the data intact. This is often the case when dealing with perceptual media like pictures and audio, because our brains have some rather powerful built-in error-correction features, but is typically unacceptable when it comes to structured data like source code or even simple text (we can also correct mangled text to some extent, but it's much more work and still relies on context being present, as usual).

I know that there is a very old gamedev.net thread where the thread author claims he's come up with a lossless compression scheme which always shortens its input. It's a fun read if you are interested in the subject. Here, I dug it out for you: clicky.

 

 

Thank you for the link!  it was quite entertaining. :)

 

My original answer got lost, so I got a bit discouraged to repeat. 

 

Mental note to self...  Do not use Google Chrome Canary to write in discussion forums.

 

awsnap.png

Edited by aregee
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0