sampling
You are currently browsing articles tagged sampling.

(Original image by Hljod.Huskona / CC BY-SA 2.0).
I used to hate neural nets. Mostly, I realise now, because I struggled to implement them correctly. Texts explaining the working of neural nets focus heavily on the mathematical mechanics, and this is good for theoretical understanding and correct usage. However, this approach is terrible for the poor implementer, neglecting many of the details that concern him or her.
This tutorial is an implementation guide. It is not an explanation of how or why neural nets work, or when they should or should not be used. This tutorial will tell you step by step how to implement a very basic neural network. It comes with a simple example problem, and I include several results that you can compare with those that you find.
Read the rest of this entry »
Tags: AI, artificial intelligence, Matlab, neural network, Octave, optimisation, pattern recognition, random, sampling

A cellular automata system is one of the best demonstrations of emergence. If you do not know what cellular automata (CA) is, then you should go download Conway’s Game of Life immediately:
Conway’s Game of Life
Essentially, CA is a collection of state machines, updated in discrete time intervals. The next state of one of these depends on the current state as well as the states of neighbours. Usually, the state machines correspond to cells in a grid, and the neighbours of a cell are the cells connected to that cell. For a more detailed explanation, see the Wikipedia article.
Even simple update rules can lead to interesting behaviour: patterns that cannot be predicted from the rules except by running them. With suitable rules, CA can simulate many systems:
- Natural phenomena: weather, fire, plant growth, migration patterns, spread of disease.
- Socio-economic phenomena: urbanisation, segregation, construction and property development, traffic, spread of news.
Read the rest of this entry »
Tags: 2D, AI, blending, cellular automata, Conway's game of life, Dev.Mag, diffusion, discrete dynamics, disease simulation, fire simulation, Game Maker, grids, optimisation, probability, random, sampling, Simulation, social dynamics, tiles
I studied computer engineering at the University of Pretoria. I worked in game development for almost three years, before I joined InnovationLab to help them create interactive simulations and serious games. I am currently doing my honors degree in computer engineering (which is why the posts are a bit slow this year
).
Some projects that I have worked on:
More music: http://www.youtube.com/user/hermantulleken2
Articles for Dev.Mag:
Email: herman.tulleken@gmail.com
Tags: AI, Dev.Mag, Game Development, Perlin noise, sampling, Simulation, tiles
Random steering is often a useful for simulating interesting steering motion. In this post we look at components that make up a random steering toolkit. These can be combined in various ways to get agents to move in interesting ways.
You might want to have a look at Craig Reynolds’ Steering Behaviour for Autonomous Characters — the wander behaviour is what is essentially covered in this tutorial. The main difference is that we control the angle of movement directly, while Reynolds produce a steering force. This post only look at steering — we assume the forward speed is constant. All references to velocity or acceleration refers to angular velocity and angular acceleration.
Whenever I say “a random number”, I mean a uniformly distributed random floating point value between 0 and 1.
Read the rest of this entry »
Tags: 2D, AI, artificial intelligence, blending, C++, Game Development, Game Maker, Perlin noise, probability, random, random distribution, random motion, random steering, response curve, Reynolds, sampling, Simulation, steering bahaviors, steering behaviours, vector field, wander, white noise

I use this code to illustrate many of the tutorials on this site, and the articles I write for Dev.Mag. Ideally, I would like to package the code so that it is the minimal necessary for the particular tutorial; however, a lot of the code is reused, so that it becomes difficult to maintain. Instead, I distribute it all together. That way, new updates and extensions can be found in one place.
The current version includes classes and functions for:
- easy-syntax 2D and 3D arrays (for example, you can use grid[1:20:2, 2:3:20] to access the pixels in every second column (starting with column 1 and ending before column 20) and every third row (starting from row 2 and ending before row 20) (docs);
- general image utility function (docs);
- perlin noise (docs, tutorial);
- poisson-disk sampling (docs, tutorial);
- texture generation algorithms (docs, tutorial);
- quadtrees (docs, tutorial part1 and part 2);
- classes for generating random points (1D and 2D) from arbitrary distributions (docs, tutorial);
- functions for blending between images (for smooth transitions between regions in seamless tile sets) [see blend_demo.py, tutorial]; and
- functions for image quilting (under construction).
A few notes:
- The code is not optimised, and in general convenience and clarity takes precedence over speed. This code is not suitable for many applications where speed is important.
- The code will change often. At this stage I do not try to make it backwards compatible.
Download
Python Image Code v0.6
python_image_code_v0_6.zip (593 KB)
Requires PIL (Python Image Library).
This version includes some of the dependencies that accidentally got left behind in the previous version.
Tags: 2D, AI, blending, Dev.Mag, Perlin noise, Python, quadtree, quadtrees, random, sampling, tiles

(Photo by Darren Hester)
Some algorithms take a long time to return their results. Whether it is because the algorithm has to operate on a huger data set, or because it has combinatorial complexity; every time you run it you have to wait minutes or even hours for the thing to finish, making errors very expensive.
This post gives some advice on how to prototype slow algorithms with as little frustration as possible. We assume that this algorithm is being implemented experimentally – that is, you will tweak it and change is often before it is finished (it is not the kind of algorithm you type in straight from a text book). For example, I used the ideas outlined here while playing with the texture generating algorithm of the previous post.
Read the rest of this entry »
Tags: 2D, AI, C++, grids, maintainability, optimisation, prototyping, Python, random, sampling, slow algorithm
For many applications, detailed statistical models are overkill. Instead, we can get away with a rough description of the distribution – not in mathematical formula form, but just as a graph with a few sample points.
For example, when trying to model the traffic around a school, you might know that the graph looks something like this:

The input is the number of minutes before the first bell rings, and the output the number of children dropped off at that time. You know that most kids are brought before the bell rings, and that the closer to the bell, the more kids are being brought every minute. Only a few kids are late.
This tutorial describes how to generate random numbers that can generate a distribution described by an arbitrary (piece-wise linear) curve, as the one above.
Read the rest of this entry »
Tags: AI, C++, distribution function, Mathematics, probability, Python, random, random number generation, response curve, sampling, Special Numbers Library
Recent Comments