Jump to content
Me.

Random Number Generator

Recommended Posts

Me.    1283

I've noticed that the standard random number generators doesn't produce truly random numbers, so I decided to build one that does. Going by humanity's collective perception of what a random number is, I've ended up with the following code in c++:

 

Quote

double random()

{

return 7;

}

 

This function only returns random numbers in the interval 1 to 10, but you could scale the output to fit other intervals.

  • Upvote 7

Share this post


Link to post
Share on other sites
mark    3104

I'm not educated on this subject enough to really understand what this means, but what is your opinion on random.org? Or is that not what you're getting at here, and is this more about being easy and useful for programming? 

Share this post


Link to post
Share on other sites
Me.    1283
3 hours ago, mark said:

I'm not educated on this subject enough to really understand what this means, but what is your opinion on random.org? Or is that not what you're getting at here, and is this more about being easy and useful for programming? 

 

This is a "random" program that always gives you 7. It's a joke on the fact that if you tell a human to come up with a random number between 1 and 10, they (almost) always say 7 because the process of elimination tells them that no other numbers are "random". So, for a human, a number is random if and only if it's 7. Therefore, I made my random program always evaluate to 7 to agree with this definition.

Edited by Me.

Share this post


Link to post
Share on other sites
mark    3104

Oh I see, the Return 7 part makes more sense now lol 

Share this post


Link to post
Share on other sites
+JC.    4725

this function is bad

you forgot the importance of seeding in random number generators

here's a much better function

public static double random(int seed){
	return seed%2==1 ? 6 : 4;
}

 

  • Upvote 2

Share this post


Link to post
Share on other sites
Me.    1283
On 2017-01-19 at 4:54 PM, JC. said:

this function is bad

you forgot the importance of seeding in random number generators

here's a much better function


public static double random(int seed){
	return seed%2==1 ? 6 : 4;
}

 

 

Seeding is only necessary to generate pseudo-random numbers. My function bypasses the technical limitations completely and gives you a truly random number by the real definition supplied above.

  • Upvote 1

Share this post


Link to post
Share on other sites
+rei+    34352

yeah damn chrona beat me to the eight year old xkcd comic making this joke

  • Upvote 4

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


  • Recently Browsing   0 members

    No registered users viewing this page.

×