• ### Best way to create random seed on [loadbang] with vanilla?

Here is my attempt:

randomseed.pd

It works okay (at least there is some variation), but I think the problem is that there is an average time for [loadbang] so the probability for some numbers is higher then for others.

• Posts 44 | Views 10999
• @Jona The problem with true randomness is that entropy from the real world is needed. There has been a discussion about that on the mailing list: https://lists.puredata.info/pipermail/pd-list/2018-05/122743.html and also a discussion here in the forum: https://forum.pdpatchrepo.info/topic/9610/true-random.

These are two solutions from the mailing list discussion:

Here are two proposals by me that don't generate actual entropy, but have pseudo-randomness by saving the previous state in the current file or an external file and use it as seed on the next start:

Both are deterministic, but will always produce unpredictable results from a human standpoint, each time Pd restarts. The second one will give an error on the first try, if seed.txt is not present.

I believe somewhere in the forum is another complex approach that uses different techniques to acquire entropy...

• @ingox I suggested electrical noise a while ago...... from a mic input....... long discussion somewhere and then this one...... https://forum.pdpatchrepo.info/topic/9610/true-random
In fact the forum is littered with dead or dying discussions of [random]
The old internet [time] object should give perfect distribution for seeding if that is what is needed.
David.

• @ingox and @whale-av thanks for the examples and thoughts. yes, [time] would be a good solution, but is not vanilla. actually unix time could be even better https://en.wikipedia.org/wiki/Unix_time, because it does not repeat every day.
But for me it is fine if the result just seems to be random. I also like the mic input idea, but then you need to have a mic connected.

• @Jona [adc~] could work if there is enough noise without a mic connected.
[timer] could work if you start it with a loadbang and then manually seed and start random from it's output....... but not what you are looking for.
Anyway....... here is a simple patch for [adc~]....... randomer.pd ....... and then "is there enough noise" without a mic attached?

Another way would be to collect some user data....... mouse data with a mouse plugin, or [key] springs to mind, or clicking on a grid...... during the previous opening of the patch..... and use that......
David.

• You could also try to somehow use data from earthquakes. The best place to start is to look in earthquakes database's in Taiwan. Taiwan has a great website to monitor earthquakes and this site has a huge database of earthquakes. Everyday there are 3-4 earthquakes in Taiwan. You could use the location coordinates of a specific earthquake and use that data to create a random generator. Here is the website : (this is a hard approach to this problem but earthquakes are really unpredictable in nature)

https://www.cwb.gov.tw/V8/E/E/index.html

.

• @Boran-Robert Yes, but God made the Earth...... still not random.......

• The problem is about measurement. Quantum behavior has a different kind of randomness. but when you observe it (aka measure it) it becomes classical randomness. You can use a classical machine to simulate a quantum system but it is just an approximation. Quantum circuit simulator :

https://algassert.com/quirk

• @Jona Whether you can collect user data depends upon what your patch is going to be doing....... in Vanilla without mouse events.
To what extent will a user interact with the patch.
It could be forced like this.......... randomyness.pd

Or you could simply capture the duration that the patch was open last time.
David.

• A while a ago i was thinking about a classical system to create random numbers. The idea was to fuse PI-calculus with fuzzy type I in a network system where you can exchange fuzzy type I sets. So the network could output a fuzzy set that could have some specific random properties. I manage to fuse them together but i was still not satisfied by the idea. Now i think that by changing the fuzzy type I to type II together with PI-calculus you can make something like a random number. The monadic-PI-calculus is just for normal fuzzy sets. The Polyadic-PI calculus is a higher order where you can send fuzzy sets of sets over the network.

• @Boran-Robert Not sure about that. Once you put effort into making something you lose the entropy.
I don't think any kind of logic is supposed to be random.
But then I don't have even a thousandth of your skill set....... .... so I am not going to argue with you about your funny squiggly symbol things.
.

• @whale-av I agree with your point. We try to usually solve different problems in a logical fashion but the nature is the way it is and it doesn't give a damn about what we think about it's way of doing things. I strongly believe that understanding this entropy could lead to a better understanding of nature. Up to now there are to many definitions of entropy and we still don't have a deep understanding of it. I apologize for the math i still think i need to simplify it to be more friendly.

• @Boran-Robert living nature is really at the complete opposite end of the scale of entropy as we are talking about it....... high.... or low...... I can't remember.
Of course earthquakes are not living.
Living things, their structures and patterns are at the same end of the scale as your funny squiggles.
Anyway, time for bed.
David.

• @whale-av Yes. The fundamental output of the brain is motion. Consciousness is just the feedback loop that colours the motion.

• @whale-av i tried the mic approach. Actually I do not need a mic connected, but a sound device. Here is an attempt with Ofelia (yes, not vanilla), it generates the seed from microseconds, so at least 1000000 possibilities a second (if there are that many different seeds)
and interestingly seed seems to accept double precision floats?

randomseed_micros.pd

Btw: It seems that only since 2016 computers can generate "real" random numbers:
https://futurism.com/scientists-enable-computers-to-generate-true-random-numbers
The result sounds quite simple and very similar to what we are trying here:
"The randomness extractor harvests randomness from two sources in the environment, such as input from the mouse or the keyboard, converting their coordinates into a string of numbers, and weeding out the predictable rubbish to end up with a true random number."

Here is the according paper: https://eccc.weizmann.ac.il//report/2015/119/
But it is too complicated for me, and I am satisfied with the (pseudo) random possibilities from Pure Data.

• Another possibility to gather entropy could be to use [netsend] to send some data though the local machine. Maybe this is not different than doing some calculations. It comes with a message about the connection. If the port is already in use, it might not work. Other than that, it looks like a possible way to go.

In the example i use the result as a seed for a [random] to spread the outcome over the complete range. This should then be used as the seed for the actual [random]: netseed.pd

In addition, the bang to reset could be removed to maybe even get a little bit more entropy from the load time.

• I don't know if this does anything with sending anything, but it has no message and should work even when the port is already in use: netseed2.pd

• @ingox thanks. here is an attempt with [array random]:

randomseed_array.pd

• @Jona I haven't tested it yet, but if [array random] works like [random], it should always produce the same quantile after a restart and thus always select a certain value from the randomly produced list, so i am not sure if there is any more entropy as just one [realtime] would produce...

• @ingox
that would be true, but i am not sure.
"array random" makes a pseudo-random number from 0 to 1 and outputs its quantile (which will therefore have probabilities proportional to the table's values.)

"array quantile" outputs the specified quantile of the array - so for instance, the 0.5 quantile is the median of the array. This generalizes the "array random" function allowing you to use the same source of randomness on several arrays, for example. Negative numbers in the array are silently replaced by zero. Quantiles outside the range 0-1 output the x values at the two extremes of the array (0 and 99 here).

So if i understand it right, the random array number depends on all array values (the median of the array). and not simply returns one of the array elements randomly?

I addition set the seed of [array random] with [array sum].
Here is a variation: randomseed_array_3.pd perhaps much too complicated anyway, i think for my needs there is enough variation in those examples.

• @Jona Yes, to set the seed that way would really take all the values into account.

Still, with such a kind of operations, it is the question, if it really adds to the entropy. For example, if you roll a dice, you get one out of six numbers equally distributed. If you roll one thousand dices and add up the results, you get numbers from 1000 to 6000, but they are not equally distributed any more.

Another example would be having a true random number between 0 and 1. If you take 1.000 numbers and take the average, it would probably be around 0.5. If you take 10.000 numbers instead, you probably get even closer to 0.5, so the entropy is actually decreased. Whether the entropy increases by taking the sum, i am not sure. But there is some randomness for sure.

Without the random seed i am pretty sure that the other numbers would not increase the entropy, as once the list is generated, the result is determined and it would not change the entropy if you instead choose another number than the selected quantile, for example the next number or the opposite number. But this is just me guessing.

Or to put it in other words: At the end of the process, you will have one number between 0 and 1 that is the result of one [realtime] operation. If it is this number or another may not make a difference.

Posts 44 | Views 10999
Internal error.

Oops! Looks like something went wrong!