Roll of the dice

A presentation at Tech Talk @ Tagesspiegel in January 2024 in by Gunnar Bittersmann

Slide 1

Slide 1

ROLL OF THE DICE Photo by Jonathan Petersson on Unsplash

Slide 2

Slide 2

ROLL OF THE DICE Photo by Jonathan Petersson on Unsplash

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

biased, DO NOT USE! Array.prototype.shuffle = function() { this.sort(()

= / }; / / / naïve method Math.random() - 0.5);

Slide 12

Slide 12

(a/k/a Knuth shuffle or Durstenfeld shuffle) Array.prototype.shuffle = function() { for (let i = this.length - 1; i > 0; i ) { const j = Math.floor(Math.random() * (i + 1)); const aux = this[i]; this[i] = this[j]; this[j] = aux; }

/ }; / / / Fisher–Yates shuffle

Slide 13

Slide 13

(a/k/a Knuth shuffle or Durstenfeld shuffle) Array.prototype.shuffle = function() { for (let i = this.length - 1; i > 0; i ) { const j = Math.floor(Math.random() * (i + 1)); [this[i], this[j]] = [this[j], this[i]]; }

/ }; / / / Fisher–Yates shuffle

Slide 14

Slide 14

Photo by Jonathan Petersson on Unsplash “Did you lose your money? You must have lost your money. If you didn’t lose your money we wouldn’t be here.” — Bruce Springsteen, intro to “Roll of the Dice” ROLL OF THE DICE