Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmhglnd committed Sep 11, 2020
1 parent 651a73c commit caa58a8
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions docs/05-ring.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ ring someSamples [kick_909 hat_909 snare_909 hat_909]
- [randomSeed](#randomseed)
- [random](#random)
- [randomFloat](#randomfloat)
- [drunk](#drunk)
- [drunkFloat](#drunkFloat)
- [urn](#urn)
- [coin](#coin)
- [dice](#dice)
Expand Down Expand Up @@ -379,6 +381,66 @@ ring rnf3 randF(5 -12 12)
// => [-1.19 -4.21 -7.36 -10.31 6.82]
```

## drunk

Generate a ring of random values but the next random value is within a limited range of the previous value generating a random "drunk" walk, also referred to as brownian motion.

**arguments**

- {Int+} -> number of values to output
- {Int} -> step range for next random value
- {Int} -> minimum range (optional, default=null)
- {Int} -> maximum range (optional, default=null)
- {Int} -> starting point (optional, default=(lo+hi)/2)
- {Bool} -> fold between lo and hi range (optional, default=true)

```java
Rand.drunk(10, 5, 0, 24);
//=> [ 13, 10, 14, 13, 14, 13, 15, 10, 8, 4 ]

// 22.00 ┼ ╭╮
// 17.80 ┼─╮╭─╮ ││
// 13.60 ┤ ││ ╰╮╭╯│
// 9.40 ┤ ││ ╰╯ │
// 5.20 ┤ ╰╯ │
// 1.00 ┤ ╰

Rand.drunk(10, 4, 0, 12, 6, false);
//=> [ 2, -2, 2, 1, -3, -1, -2, -1, 3, 6 ]

// 2.00 ┤╭╮
// -0.20 ┤│╰╮ ╭
// -2.40 ┼╯ ╰╮ │
// -4.60 ┤ │╭╮ ╭╯
// -6.80 ┼ ╰╯│╭╯
// -9.00 ┤ ╰╯
```

## drunkFloat

Generate a ring of random floating-point values but the next random value is within a limited range of the previous value generating a random "drunk" walk, also referred to as brownian motion.

**arguments**

- {Int+} -> number of values to output
- {Number} -> step range for next random value
- {Number} -> minimum range (optional, default=null)
- {Number} -> maximum range (optional, default=null)
- {Number} -> starting point (optional, default=(lo+hi)/2)
- {Bool} -> fold between lo and hi range (optional, default=true)

```java
ring dr1 drunkFloat(5);
//=> [ 0.493, 0.459, 0.846, 0.963, 0.400 ]

// 0.88 ┼╮╭╮
// 0.76 ┤╰╯│
// 0.63 ┤ │
// 0.51 ┤ ╰╮
// 0.39 ┤ │
// 0.26 ┤ ╰
```

## urn

Generate a list of unique random integer values between a certain specified range (excluding high val). An 'urn' is filled with values and when one is picked it is removed from the urn. If the outputlist is longer then the range, the urn refills when empty. On refill it is made sure no repeating value can be picked.
Expand Down

0 comments on commit caa58a8

Please sign in to comment.