• 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
Kaptein

Sums of uniform randoms

11 posts in this topic

This is my last resort after 2 days of devouring information from everywhere [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
My math skills are relatively poor though, but I have a feeling what I'm trying to do simply can't be done.

I am summing random variables that have uniform distribution, once they are summed they are of normal distribution
With only n = 3, the distribution is already extremely poor.
How can I, and is it even possible to make the distribution uniform again?

This is the ultimate example:

[source lang="cpp"]
for (1 ... N) {
X += uniform();
}

X = uniformize(X, N);
[/source]

http://www.johndcook.com/blog/2009/02/12/sums-of-uniform-random-values/
the density function for my final distribution should be a constant 1/N
[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Kaptein
0

Share this post


Link to post
Share on other sites
that's just scaling, i need octaves to build a frequency
a real life example would be uniformly distributed whitenoise Edited by Kaptein
0

Share this post


Link to post
Share on other sites
I am not sure what you want to accomplish.

If you want a random variable with uniform distribution from 0 to N, and you have a variable uniformly distributed from 0 to 1 well then you just have to scale it with N.
I do not see the point in creating a random variable with some distribution and then wanting to transform it back to uniform, if you actually have a uniform distribution to begin with.
1

Share this post


Link to post
Share on other sites
I have a feeling you might be confusing the concept of random variable and probability distribution. Could you tell us exactly in detail what you are trying to do?
0

Share this post


Link to post
Share on other sites
If you only have an API that allows you to generate uniform bits (0 or 1), you can generate a random number in the range [0, N] in the following way:
[code]
int uniform(); // Returns 0 or 1 uniformly at random.

uint32_t RandomNumber(int N)
{
uint32_t NPow2 = largest power-of-2-number smaller or equal to N.
int i = 1;
uint32_t result = 0;
while(i <= NPow2)
{
if (uniform)
result |= i;
i <<= 1;
}
return (uint32_t)((uint64_t)result * (N+1) / (NPow2 << 1));
}
[/code]

However, this is most likely not the route you want to go through, unless you somehow have a very special setup where your RNG can only supply individual random bits. That sounds rare, and instead most RNG sources are built-in to produce random integers in range [a,b] and random floats in the range [0,1] (which equals roughly 23 bits of randomness).
1

Share this post


Link to post
Share on other sites
[quote name='clb' timestamp='1351870588' post='4996559']
However, this is most likely not the route you want to go through, unless you somehow have a very special setup where your RNG can only supply individual random bits. That sounds rare, and instead most RNG sources are built-in to produce random integers in range [a,b] and random floats in the range [0,1] (which equals roughly 23 bits of randomness).
[/quote]
These special setups are not rare at all, though I agree you are more likely to find them in cryptographic settings (entropy pools) than in conventional PRNG's. Also, a small terminology nitpick: a random bit generator is called an RBG (and its pseudorandom counterpart is a PRBG).

What I would find rare is PRNG's directly producing floating-point numbers. As far as I can tell this is usually provided by a helper function which performs the floating-point division along the lines of random(max) / max. I recall a few purely floating-point generators, but in my opinion it's not a very smart way to go about it, integer arithmetic is very well-defined unlike floating-point arithmetic.
1

Share this post


Link to post
Share on other sites
I asked a statistician, and I got a final answer: that i couldn't do this due to central limit theorem
When i sum random samples, I am destined to get a skewed probability distribution
nevertheless, interesting conversations above :)
0

Share this post


Link to post
Share on other sites
Well, not if your uniform random distributions are not independent. The central limit theorem does not apply, and you can build a uniform distribution U(0,7) as the sum of seven U(0,1) distributions that happen to be identical.

But I still don't quite understand what you were trying to do, so this conversation feels kind of irrelevant.
0

Share this post


Link to post
Share on other sites
i was using the randoms to create octaved frequencies for biomes
i didnt want noise, since gradiented noise has extremely uneven distribution (think of the derivatives on the extremities of a sphere)
i basically wanted to make saw-like linear frequencies

but...
[url="http://www.johndcook.com/blog/2009/02/12/sums-of-uniform-random-values/"]http://www.johndcook...-random-values/[/url] Edited by Kaptein
0

Share this post


Link to post
Share on other sites
You can transform a uniform distribution into something usable for, say, minecraft-style biome generation, but it's much more involved than just summing up distributions. Look into fractional brownian motion, perlin noise, etc...

The graphs on the page you link are probability distribution functions, which map any output number to its probability of being generated (well, actually, since we're looking at a continuous range of values, it's really the probability of generating an output between some A and B). They don't mean anything else and a normal distribution will still have a large variance.

Fractional brownian motion seems to be the closest thing you are looking for. Basically, it will take a sample of uniformily generated random numbers, and output a sample of "smooth" noise, which when mapped to a heightmap, would give a somewhat realistic terrain instead of a completely random mess. It involves summing up octaves of the same uniform sample, with different frequency and amplitude. Is this what you were looking for?
1

Share this post


Link to post
Share on other sites
yes, i scrapped my plans for 1D (linear sums) and later weighted voronoi diagrams..
now im indeed using fBms and simplex
[url="http://jpdict.ath.cx:8181/files/biome2d.png"]http://jpdict.ath.cx...les/biome2d.png[/url]
and all is well [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

the problem isn't really related to determining the biomes, it's determining the terrain... in real life the terrain determines the biome to some degree
but i'm about to cross that bridge now, so not sure yet Edited by Kaptein
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