"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

@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) 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 for many uses.

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: