-2

I read an article at one point about a function, which I believe had a name like Piersen or Poisson, used to get random numbers that are close to the previous one. Apparently, it is used in some appliances, and widely used in robotics as described in the article. Here's the original example:

Say you were to be building a robot with two wheels. You want this robot to follow some random path around the room, not going anywhere in particular, turning random amounts at random times. If you were to feed a true random number generator into each wheel, the robot would most likely jerk and spin in place rather than follow some path. The goal isn't for the robot to travel in a stark straight line, rather just to look like it has some logic behind its movements.

Thus exists this function, a continuous yet randomly varying function that curves up and down as it pleases. By taking outputs at a set interval from the function (starting at 234.198, interval of 0.01 for example), one can be guaranteed that each value being sent to a wheel is random, but follows some path along with previous and future values. By choosing a greater or lesser interval, the degree of relationship between consecutive values can be changed to essentially make a progressively more or less intoxicated robot.

What is the name of this function?

TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46
  • 1
    I'm voting to close this question as off-topic because it has nothing to do with programming. – Alexander Sep 08 '15 at 06:21
  • Brownian motion (gaussian random walk) https://en.wikipedia.org/wiki/Random_walk – Alexander Sep 08 '15 at 06:22
  • @Alexander It has more to do with computer science than programming, but is less likely to be known by name to computer scientists, who spend time researching new methods, than programmers, who stick to tried and true methods, hence the question belonging here. Also, I'm familiar with the theory, but after hours of googling I still can't seem to find the function name I am looking for. – TheEnvironmentalist Sep 08 '15 at 06:28

2 Answers2

1

Autoregressive models may be what you are looking for. This is a class of models which use weighted past history combined with some drift/randomness to determine the next value.

pjs
  • 18,696
  • 4
  • 27
  • 56
0

I know of a Poisson distribution but I'm not sure it's relevant here.

If you want a random walk down Main street sort of situation, I'd suggest just adding a small delta to the current value to ensure small steps.

def nextValue(n):
    return n + random(7) - 3

Something like that will always give you a value +/- 3 from the current value, though you can adjust the expression for bias, using random(4) - 1 for example if you prefer forward motion over time.

For a robot that you want to meander forward smoothly, you could set an overall distance then periodically add extra forward motion to a specific wheel over the lifetime of the motion, something like:

def meander():
    distance = random(10,25)       # 10-25 units
    skip = distance / random(3,5)  # curve at 33/25/20% points
    direction = random(1,3)        # curve left, right or not at all
    for i = 1 to distance:
        leftdelta = rightdelta = 1 # Default to one unit forward

        if i is multiple of skip:  # Periodically adjust one wheel only
            case direction:
                1: leftdelta--
                3: rightdelta--

        leftwheel += leftdelta     # Turn wheels
        rightwheel += rightdelta

def drunken_monkey():
    while true:
        meander()

Something like that should give you forward motion for a time along a gentle but random curve, before adjusting the curve of motion for the next step.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953