"Random" in TW -- Practical Issues & Q's

I put this under “Developers” 'cause I thought it likely better than “Café”.

I’m about to start a wiki that wants to …

1 - Emulate (some aspects of) the Burroughs Cut-up method;
2 - … via self-interrogation of Tiddlers (200) of larger texts (500 sentences each Tiddler);
3 - … to extract Random Sentences from those;
… such that …
4 - … Random (in numbers) of sentences are Extracted from a Tiddler;
5 - … and that are Randomised in the final output ordering;
6 - … to an Output Tiddler of the Randomly Selected sentences.

Assumption: The quality of the Randomness will depend on JS (?)

Q1: Has anyone here used randomness a lot in TW? (who might help me)

Q2: Is the validity of Randomness via JS documented/tested anywhere?

Thanks for any indulgence/help to answer my serious queries.

Best, TT

The main problem with randomness in TW is, that if it is a filer-operator, which it should be for origin usecases. A random number will be created everytime the tiddler is rendered.

So the output will be changed every time the tiddler will be opened. – So it depends if that is something
you want.

For this type the built-in JavaScript functions can be used.


If you still want randomness, but with a repeatable outcome, to allow re-rendering, we will need a “seed value”. This seed-value can be random and will be fed into a “pseudo random” generator which will create the same “random” numbers depending on the seed.

Since the seed-value itself is random in sum the whole thing is random, but is still called a “pseudo random” number generator. — Not sure if that makes sense :wink:


If implemented in a naive way, the output will not be random at all. – Luckily there is an algorithm which we could use.

  • It creates a seed, that technically will never repeat in a session
  • We will get almost unlimited unique seeds (2.132 x 10468) before they repeat
  • We will be able to create any amount of random numbers using a range eg: 10000
  • So it will create numbers between 0 and 10000-1 → 0000 - 9999
  • We can create as many as we want

The advantage of the seed-value is:

  • It can be stored and shared
  • So if you have one, which creates an interesting output from your “Burroughs Cut-up” texts you can easily share it with others
  • The initial seed can be created with the TW startup actions and
    • the seed can be stored in a temporary tiddler
    • So users can decide if they want to keep them or not

Filter Operator

A new uheprng filter operator could look like this:
uheprng … Ultra-High Entropy Pseudo-Random Number Generator. (not my name :slight_smile: )

[uheprng[<range>],[<count>],[<seed>]]

eg:
[uheprng[10000],[20],[random string or tiddler title]]

Which may create 20 random numbers in the format of 0000 - 9999

Would this be something you thought about?


We will also need a <$uheprng (action)-widget, which can expose the other API elements that are needed. The parameters are not clear atm.

There is no TW related code and no commitment
-m

1 Like

@pmario That was incredibly informative! And helpful.
I will go into your suggestions as I try develop the tool.

Thank you.

It does.   

p.s. Why did I have to add to “It does.” the string “&nbsp;&nbsp;&nbsp;” to get it to post?

If you want an example wiki using precisely this technique, you can investigate my Bullshit Bingo wiki.

We have a startup action, $:/_/bb/actions/choose-random that uses a pseudo-random number generator to pick an initial seed value for the wiki and stores it in a temporary value, that is then picked up as the first of my $:/DefaultTiddlers. It will be something like Card_561 or Card_42. These are virtual tiddlers whose entire content is derived from the numeric id via a template that uses a module that (for some reason lost to fading memory) contains another copy of that same randomizer.

The important point is that these are repeatable pseudo-random numbers. Called with the same seed, they will report the same sequence of random-enough values on every use.

The trick here to escape the issue @pmario describes is to start the wiki off with randomizing seed values for anything you want to be static across the visit. In my case, it’s just the default tiddler than I need to initialize, but the same thing should work fine for dozens or hundreds of things that need randomization. And if you can associate a number with your values, you don’t need to do anything up front: just use that number as a seed, as I do with the card numbers.

And hey, while you’re there, if you have suggestions for snarky definitions of my still-to-be-defined terms, feel free to share! :slight_smile:

2 Likes

Bingo! From the bottom of my left ventrical, thanks.

That is a super useful training tool for me.

It is also a fun wiki.

P.S. My take on your definitions may not be your style.

Data Mining = Eugeneification

Thanks. Its predecessor was one of my very first JS projects, back in the document.all vs document.layers days. I’m pretty sure it was all document.write, if any of that means something to you. I remember tweaking it to use CSS when I could and it just sat around for two decades until I decided I wanted to do a Devil’s Dictionary-style version. Since then, I’ve very slowly been adding definitions.

Speaking of which,

Thanks! Ummagumma is one of those albums for which I still haven’t replaced my old vinyl (perhaps cassette) with CDs. While I do still listen to that older stuff on occasion, I’ve never digitized it, and it’s pretty rare. It’s probably 10 - 15 years since I heard Eugene. An old friend.

I’ll have to think whether I want to use it. Most of my definitions are entirely unsubtle. Here I’m not even sure of which of two potential connections you want to make: Eugene → Axe → Dwarves → Mining, or Eugenics → awful usage of data mining. Or both. But a great suggestion, whether or not I choose to use it.

I will just add to this thread something often overlooked and that is people dont actualy mean random, like rolling a dice every time, what they really mean is like a random shuffle of a playlist.

To address this generate a random list then as you “play” each item remove it from the list so it is not replayed again, or get more sophisticated and add an instance counter, then dont allow replay unless the current instance is greater than N distance from the last play eg; never replay unless more than one hundred other items were played first.

2 Likes