Randomness is a concept with relevance to many different fields and areas of life, from mathematics to computing science and the arts. There are actually lots of different definitions of randomness, for its uses in these different contexts. In this article we'll go over what it means for something to be random, as well as looking at the application of randomness in computer programming and the arts.
I started thinking about randomness when I was developing my Android Nonsense apps, see also this post: Using Randomness to Stimulate Creativity
What Is It Anyway?
In one sense, something being random means it being unpredictable. In another sense, it means having no discernible order. If some sequence of events appears not to conform to any sort of order, this implies that it has not been arrived at through a dedicated method. When something happens as a result of some process in which there is a purpose, this does not normally create random results. In some cases randomness is used in an intuitive sense, while in others it has a very specific objective definition. In mathematical contexts, random sequences are often referred to in conjunction with notions of probability and predictability.
Computer Programming
Randomness is a common topic in computer programming. Often, computer programmers use language utilities known as random number generators. These allow programs to generate a series of numbers with specific parameters, for example within a certain range or with a certain number type such as integer or floating point. Programmers use these for various tasks, some relating to underlying application logic, some relating to user interaction. For example, random functions can be used to present content items to application users in a way that creates a different user experience each time.
Although random number generators are common in computer programming, the numbers produced are not actually truly random. This is because it is impossible, by definition, for a computer program to generate a random series of numbers. In order for a series to be random, there can be no process or method used to generate it, but a computer can only generate numbers using a detailed, specific process. In brief, this means that if a series is generated by a computer, it is not random.
While not truly random, the random number generators used in computer programming are designed to create the appearance of randomness to the end user. For example, if you use a music player such as an MP3 player, you will be familiar with shuffle functions. With a shuffle function, the application uses a random number generator to choose songs from those available. There is in fact another obvious way in which these functions are not really random in addition to the fact that they are computer generated. This is that fact that most shuffle functions are designed not to repeat songs, but rather to play each available song once before playing any one a second time. Again, the randomness here is in appearance rather than strictly in reality.
The Arts
Another common area to experience randomness is in the arts, particularly in comedy contexts. Many people find randomness produces results that are funny, for example through gibberish, or nonsense speak in which people combine random combinations of words. Some computer programs combine this with the random number generation functions to generate random sentences for comic effect. Some songwriters also use randomness to come up with lyrics and song titles.
Randomness is also involved in art in a creative sense. Many people find randomness is a great way to stimulate them creatively. This can involve using computer programs again, for example to generate random words or pictures. The unpredictability of randomness produces surprising results that appear to stimulate the creative functions within the human brain.
Life
We experience randomness in many areas of life, from the weather to throwing a dice or shuffling a deck of cards. In many cases you see random sequences and are not aware of it, and in many more you see sequences that appear to be random but are in fact not. Whatever way you look at it, randomness is a part of life.
See also
Random Number Generators
Using Randomness to Stimulate Creativity
Tutorials, tips and guides on computing/ information technology for users and developers.
Showing posts with label random. Show all posts
Showing posts with label random. Show all posts
Friday, 31 August 2012
Monday, 27 August 2012
Random Number Generators
Randomness is a common ingredient in computer programming, sometimes for functions you may not become aware of as a user, and sometimes for visible effects. My Android apps use randomness, partly for comic effect, partly to create a more dynamic user experience and partly to stimulate creativity, as I explored in this article: Using Randomness To Stimulate Creativity.
Anyway, the project got me thinking about randomness generally, as it's a fascinating topic. In this article I'll go through the basics of how randomness and random numbers are involved in computer programs.
Uses
Many computer programs use randomness to create dynamic, unpredictable effects. These programs typically use random number generators, which are provided as standard within most of the major languages for desktop and Web programming. For example, a computer game could use a random number generator to choose numbers between 1 and 6 to simulate a dice throw. Shuffle functions in media players sometimes also use random numbers to choose songs and implement play-lists.
The field of security in computer technology also often involves random number generation, particularly when encrypting data.
Random functions within Web development implement various tasks, such as presenting the user with randomly select content from a data source each time they visit a site. This allows developers to maximise on the amount of content they have for a particular Web project. Sites referred to as Web 2.0 often use these functions, particularly when they contain interactive features such as polls.
Random numbers are also often used to prevent caching issues in Web development projects. For example, sites use AJAX functions to fetch new data from a server while the user is viewing a page. In these sites, JavaScript functions within the Web page call PHP or other server side scripts running on the server, which respond with new data, sometimes from a database and formatted in XML. The scripts then write this new data into the Web page. However, developers often encounter problems with caching, in which the user's browser fails to update the content because it has cached it. By passing a random number to the AJAX functions, developers can avoid these caching issues.
Random Number Generators
Programming languages provide standard classes, functions and utilities for random number generation, allowing programmers to generate random values within particular ranges. The first thing to understand about these utilities is that they do not actually generate numbers that are truly random.
By definition, it's not possible to create a computing algorithm, or process, that has random results. Instead, random number generators produce pseudo-random values. Some random number generators are better than others, but in general they aim to produce sequences of numbers that appear random to human observers. The random numbers are normally produced using arithmetic calculations, but most programmers can use them without understanding anything about the underlying process.
Programmers sometimes also need to generate series of non-repeating random numbers. For example, in a typical series of random numbers within a limited range, for example between 1 and 10, you will see the same numbers appearing more than once. To create a series of random numbers without duplicates, programmers need to store the numbers generated in a data structure such as an array, checking each new value against the existing values before accepting the new one into the sequence. These programming activities typically involve control structures such as loops and conditional statements.
Issues
As mentioned above, some random number generators are better than others. Anyone who has tried using them in programming tasks will be well aware of how frustratingly repetitive they can be. As a user, if you've ever felt your music player was repeating the same songs all the time, you might have been right!
Alternatives
The only way to generate truly random numbers is by taking them from naturally random data, which is what services such as the Random.org site do. You can use it to choose lottery numbers, toss coins and pick cards in a more realistic way than most computer programs can produce.
However, for most computer programming purposes a pseudo-random number generator is sufficient and relatively easy to use.
Related Resources:
Anyway, the project got me thinking about randomness generally, as it's a fascinating topic. In this article I'll go through the basics of how randomness and random numbers are involved in computer programs.
Uses
Many computer programs use randomness to create dynamic, unpredictable effects. These programs typically use random number generators, which are provided as standard within most of the major languages for desktop and Web programming. For example, a computer game could use a random number generator to choose numbers between 1 and 6 to simulate a dice throw. Shuffle functions in media players sometimes also use random numbers to choose songs and implement play-lists.
The field of security in computer technology also often involves random number generation, particularly when encrypting data.
Random functions within Web development implement various tasks, such as presenting the user with randomly select content from a data source each time they visit a site. This allows developers to maximise on the amount of content they have for a particular Web project. Sites referred to as Web 2.0 often use these functions, particularly when they contain interactive features such as polls.
Random numbers are also often used to prevent caching issues in Web development projects. For example, sites use AJAX functions to fetch new data from a server while the user is viewing a page. In these sites, JavaScript functions within the Web page call PHP or other server side scripts running on the server, which respond with new data, sometimes from a database and formatted in XML. The scripts then write this new data into the Web page. However, developers often encounter problems with caching, in which the user's browser fails to update the content because it has cached it. By passing a random number to the AJAX functions, developers can avoid these caching issues.
Random Number Generators
Programming languages provide standard classes, functions and utilities for random number generation, allowing programmers to generate random values within particular ranges. The first thing to understand about these utilities is that they do not actually generate numbers that are truly random.
By definition, it's not possible to create a computing algorithm, or process, that has random results. Instead, random number generators produce pseudo-random values. Some random number generators are better than others, but in general they aim to produce sequences of numbers that appear random to human observers. The random numbers are normally produced using arithmetic calculations, but most programmers can use them without understanding anything about the underlying process.
Programmers sometimes also need to generate series of non-repeating random numbers. For example, in a typical series of random numbers within a limited range, for example between 1 and 10, you will see the same numbers appearing more than once. To create a series of random numbers without duplicates, programmers need to store the numbers generated in a data structure such as an array, checking each new value against the existing values before accepting the new one into the sequence. These programming activities typically involve control structures such as loops and conditional statements.
Issues
As mentioned above, some random number generators are better than others. Anyone who has tried using them in programming tasks will be well aware of how frustratingly repetitive they can be. As a user, if you've ever felt your music player was repeating the same songs all the time, you might have been right!
Alternatives
The only way to generate truly random numbers is by taking them from naturally random data, which is what services such as the Random.org site do. You can use it to choose lottery numbers, toss coins and pick cards in a more realistic way than most computer programs can produce.
However, for most computer programming purposes a pseudo-random number generator is sufficient and relatively easy to use.
Related Resources:
Sunday, 26 August 2012
Using Randomness To Stimulate Creativity
As part of my Android development projects, I've recently been reading about randomness and how it can help to stimulate the creative process. I've always found randomness interesting and in some cases funny, but it also seems to be a tried and tested creativity technique. In this article I thought I'd run through a few of the concepts and resources I've come across on the subject.
Lots of writers, artists and musicians use randomness to prompt their creative efforts, and computers are offering new ways to implement random (or pseudo-random) processes. Computer programming languages are able to generate random numbers which can then be used to add a level of unpredictability to website or computing application content.
I find randomness really funny, which is why I started learning about this subject, mainly for the purpose of developing my Android Nonsense applications.
Looking for a way to automate nonsense and gibberish, I found a load of funny websites doing similar things. These applications use recognisable language structures with random elements to create comic effect. Here are some of the funnier sites I've found:
Computation
When I studied for my Masters degree in IT, I worked on a software project in which sentences were modelled as templates, with placeholders corresponding to particular parts of speech. For example, the following sentence:
Could be represented using the following placeholders:
Using this idea, you can take a language template and fill words of each part of speech into the placeholder slots randomly. This process could result in the following:
The process here is a little like the game MadLibs, in which you choose words without knowing the sentence (or story) context. My idea was to make the process a little more unpredictable and to automate parts of it, rather than the user having to choose every item.
Language Use
Anyway, it works because of the difference between grammar and semantics. Grammar determines (or describes) the structures that are used within a language to build sentences and clauses. Semantics on the other hand relates to meaning. Chomsky created the following sentence to illustrate the fact that a sentence can make no sense but still be grammatical:
This is the crux of the nonsense sentence. If it was just a series of words it wouldn't be funny, but the fact that our brains recognise it as a sentence structure makes the lack of sense humorous. At the phrasal level, the concept of snowclone is also relevant. This idea relates to a category of language cliches in which a structure has interchangeable elements, for example:
Speakers of a language develop the ability to fill in blanks, an aspect of language learning analysed using Cloze Tests. This tendency to conceive of sentence structures rather than just concrete examples of language seems key to both creativity and understanding.
Creativity
Creativity is a slippery topic. We describe people as creative, generally categorising some people as more creative than others. I don't know if I believe this. I've always tended to "do creative things" but I think it has more to do with habit than nature. In any case, I believe that engaging with creative tasks is not only enjoyable, but also good for mental well-being. For this reason I think it's a good idea to encourage people to stimulate their own creativity, and randomness can aid this process.
Jabberwocky
Lewis Carroll's poem Jabberwocky touches on some related concepts. The poem, an example of Literary Nonsense, uses recognisable structures with nonsense words. Rather than each word being from a known part of speech, these words seem to be from specific parts of speech on account of the sentence structures they appear in. Interestingly, linguistic studies have shown that people often have similar ideas for what the invented words in the poem could mean.
Related Links:
Tech Interpreter Links:
Lots of writers, artists and musicians use randomness to prompt their creative efforts, and computers are offering new ways to implement random (or pseudo-random) processes. Computer programming languages are able to generate random numbers which can then be used to add a level of unpredictability to website or computing application content.
I find randomness really funny, which is why I started learning about this subject, mainly for the purpose of developing my Android Nonsense applications.
Looking for a way to automate nonsense and gibberish, I found a load of funny websites doing similar things. These applications use recognisable language structures with random elements to create comic effect. Here are some of the funnier sites I've found:
- Name Generator Central: Generator Land - This site has loads of great random generators - well worth a browse.
- Daily Mail-o-matic - It's that simple - this gives you a new Daily Mail headline every time you click the button.
- Random Fantasy Novel Title Generator | Fantasy Literature - This page generates fantasy novel titles - it's pretty funny.
- Random Sentence Generator - This simple page demonstrates the sentence generation process.
- Insult Generator: The Insult Project - This site generates funny insults
Computation
When I studied for my Masters degree in IT, I worked on a software project in which sentences were modelled as templates, with placeholders corresponding to particular parts of speech. For example, the following sentence:
The quick brown fox jumps over the lazy dog.
Could be represented using the following placeholders:
Determiner adjective adjective noun verb preposition determiner adjective noun.
Using this idea, you can take a language template and fill words of each part of speech into the placeholder slots randomly. This process could result in the following:
A stupid big car dances on a purple hat.
The process here is a little like the game MadLibs, in which you choose words without knowing the sentence (or story) context. My idea was to make the process a little more unpredictable and to automate parts of it, rather than the user having to choose every item.
Language Use
Anyway, it works because of the difference between grammar and semantics. Grammar determines (or describes) the structures that are used within a language to build sentences and clauses. Semantics on the other hand relates to meaning. Chomsky created the following sentence to illustrate the fact that a sentence can make no sense but still be grammatical:
Colorless green ideas sleep furiously
This is the crux of the nonsense sentence. If it was just a series of words it wouldn't be funny, but the fact that our brains recognise it as a sentence structure makes the lack of sense humorous. At the phrasal level, the concept of snowclone is also relevant. This idea relates to a category of language cliches in which a structure has interchangeable elements, for example:
The ? from Hell
Speakers of a language develop the ability to fill in blanks, an aspect of language learning analysed using Cloze Tests. This tendency to conceive of sentence structures rather than just concrete examples of language seems key to both creativity and understanding.
Creativity
Creativity is a slippery topic. We describe people as creative, generally categorising some people as more creative than others. I don't know if I believe this. I've always tended to "do creative things" but I think it has more to do with habit than nature. In any case, I believe that engaging with creative tasks is not only enjoyable, but also good for mental well-being. For this reason I think it's a good idea to encourage people to stimulate their own creativity, and randomness can aid this process.
Jabberwocky
Lewis Carroll's poem Jabberwocky touches on some related concepts. The poem, an example of Literary Nonsense, uses recognisable structures with nonsense words. Rather than each word being from a known part of speech, these words seem to be from specific parts of speech on account of the sentence structures they appear in. Interestingly, linguistic studies have shown that people often have similar ideas for what the invented words in the poem could mean.
Related Links:
- You are Sooo Random! - Randomness & Creativity Research | Psychology Today - Interesting psychological look at randomness and creativity.
- Random Stimuli - Mycoted - Overview of using random stimuli for creative acts.
- Aleatoricism - Wikipedia - Another creativity technique involving randomness.
- Creativity Games - Brain Training for Creativity and Creative Thinking - Simple games and resources that will improve your creative thinking and problem solving ability.
- Android Development - More info about my Android apps.
Tech Interpreter Links:
Subscribe to:
Posts (Atom)