Archive

Posts Tagged ‘random’

Name randomizer

August 20th, 2010 Niels No comments

When people think of a name randomizer, they usually mean 1 out of 3.

  1. A random name generator. A  program that makes random names from scratch
  2. A  small app that choose random names from a list. Could be a “choose student to answer a question” radomizer
  3. A application that take the names from a known group of people and randomize the output from a known input

In this post I’ll show you how you make all of these 3 different kinds of name randomizers. It’s quite easy, and you can found both tutorials and  download name randomizer scripts here at my blog. Just keep reading.

1. The random name generator

The first example of a name randomizer is the classic random name generator. The random name generator takes a bunch of names, mix them all together and randomize the output. At my name generators web site you can find a lot of different classic name generators in a whole lot of categories.

If you wanna make your own a name generator take a look at this description of  how you make a name generator. Or download my complete name generator script. It’s thoroughly commented and described and therefor very easy to adjust to your own likings and ideas.

2. Choose a random student

If you want a name randomizer that pick a student from a list, you need another sort of random application. In this JavaScript tutorial: choose a random person, I guide you through the process of how you make your own name randomizer, you can use for choosing students for questions.

This randomizer tutorial was made for a teacher, who needed an application to choose a random student from a list. In the blog post you can also find a choose student script ready for download. You just need to add the names of your students.

3. Randomize known or famous names

This is basically the same as the the classic name generator. The only different is the content you choose to fill in the the arrays or name list.

You can make a guitarist name generator by using the names from world famous guitarist, or what about a dictator name generator, a politician name generator. Or could make a script that randomize the names of all the guest to your next big party. That could be fun. Sky is the limit. ;)

It’s very easy to do. Just grab my name generator script, read the how to (check the first item in this list)  and add you own names and ideas.

Your name randomizer

As always. If you make a cool randomizer, application or other online gadget throw a comment and tell me and the world about it. :)

Choose random person

July 25th, 2010 Niels No comments

I made a little script that choose a random person from a list.

The background is that I got this mail from a reader, who need to  choose a random student from his class to answer questions.

Tom wrote:
I am a teacher and we have to randomly choose students to call and answer questions.  Right now we use popsicle sticks with name on stick.  I would like to be able to set up 4 classes,  type in the names of the students from the class and have the app pick a name out of that class randomly.

Beside choosing persons randomly such a random app  also can be used to random pick all kinds of objects or items from a list. Script is programmed in JavaScript.

Choose random person script

Here’s a very simple but useful script, which choose a random student  from a list of names.

function choose_student(){
// Add your own student names to the class list
var class_list =  ["Marge","Maggie","Lisa",
"Bart","Homer","Apu","Burns"];

// Random numbers are made
var randomNumber = parseInt(Math.random() * class_list.length);

// Student are chosen from the class array with the random number
var name = class_list[randomNumber];

// Name is shown in alert box
alert(name);
}

  1. First you make an array (a list ) with the names of the persons you want to choose from
  2. The Math.random() makes random numbers between 0 and 1. By multiplying it with the numbers of students of the list (found with the length function) and flooring it all with the parseInt() function, we will get a number between 0 and numbers of students in the class minus 1.
  3. The person in the position of the random number is extracted from the list and saved in a variable. (the item in the first position in an array is called with the index number 0 like this: myArray[0])
  4. Finally the chosen students name is shown in JavaScript alert box.

And finally you just need to call the “choose random student”-function from your HTML.

<input type=”button” value=”Chose Random Student” onclick=”choose_student()” />

Download example script

You can download an example choose random person script here. In the script you can find both the above pick random person script and the pick random student script I made for Tom. All is integrated in a complete HTML file ready to launch in your favorite browser.

The example script is integrated roughly into my name generator script, but it should give a good overview over how to accomplish the task of picking random persons from simple lists, and how to integrate a simple random application into a HTML page.

Is it the above method truly random?

In short no, but semi randomness is sufficient and adequate for the purpose of selecting random persons for none scientific reasons.

Read more about true random numbers and names.

clipped from web.archive.org
http://web.archive.org/web/20011027002011/http://dilbert.com/comics/dilbert/archive/images/dilbert2001182781025.gif
blog it

Random numbers and random names

February 14th, 2010 Niels No comments

One of the basic things in making  good name generators is random numbers. But how to create random numbers, random names and how is true randomness defined?

True randomness

At Princeton University radomness is defined as:  randomnessthe quality of lacking any predictable order or plan.

100% unpredictability and true randomness can only be generated from genuine chaotic systems.  A chaotic system is defined by it’s unpredictability lack of plan. Therefore you need a chaotic system  to guarantee true randomness.

In nature we find chaotic systems in the atmosphere or in the universe. True randomness can be generated or ‘extracted’ from these systems in form of atmospheric noise of the atmosphere or the background radiation  from the universe.

In scientific work and research  true randomness is of course crucial to avoid wrong conclusions.  Also when it come to gaming for money true randomness is very important to guarantee random results and credibility to the owner of the game.

To generate true random  numbers visit the random.org random number generator, which generate random numbers from the randomness of atmospheric noise.

Read much more about Random number generation at the Wikipedia.

Pseudo randomness

Randomness and random numbers generated from computers are not truly random, but are referred to as pseudo random numbers.
Computers are predictable by design, and mathematical  formulas and algorithms on which computers base their random calculations are both predictable and logical by nature.

The consequence  is that random numbers generated by computer in theory is predictable and therefore only pseudo random. In practical use though, it  takes  many resources and computer power to predict computer created pseudo random numbers.

Read more about pseudo randomness and pseudo random algoritms at  pseudo random number generation at the Wikipedia. Or this article about  pseudo random numbers and determinism in computer languages and software.

Pseudo-random Numbers and Determinism

In practical use the random numbers from a computer random generator in sufficient for most purposes. So random name generators is  usually based on pseudo random numbers from a programming language. I for example use JavaScripts build in random functions to create my random numbers.

From random numbers to random names

The random number generator is the motor in all name generators.  The random number generator gives surprising and unpredictable names, when used correct.

As an example look at the random name generator, which generates random American names. 1000 boy names, 1000 girls names and 1000 surnames are combined with random algorithms and forms over4 billion random names:

The math behind the random name generator:

1000 girl names x 1000 surnames  = 1,000,000 unique girl names

1000 boy names x 1000 surnames  = 1,000,000 unique boy names

And by sometimes adding a middle name:

1000 girl name x 1000 boy middle names x 1000 surnames  = 1,000,000,000 unique girl names

1000 girl name x 1000 girl middle names x 1000 surnames  = 1,000,000,000 unique girl names

1000 boy name 1000 boy middle names x 1000 surnames  = 1,000,000,000 unique boy names

1000 boy name 1000 boy middle names x 1000 surnames  = 1,000,000,000 unique boy names

In total 4.2 billion unique and random names