Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

Julien Tayon: Using python to visualize randomness

$
0
0
Heard of randomness?

What is random: something that given a serie of chronological events (happening after one another) whatever long the time serie is, we cannot predict the future.

Two kinds of events are random; purely random events (stochastics) or mathematically deterministic equations that are so sensitive to initial conditions that they are very hard to predict.

PRNG is the second kind of beast.

Takens series are an intuitive way of trying to see if something is random in a space phase. Here because our brain is limited I took only 3 dimensions. Anyway maplotlib sux at doing projections from n dimensions to 3 in a way that is easy to see.

You take segment of time series and you make linear visualization of the serie in function of its former self. And for the fun I added an alpha (the more you are in the past, the fader the color is), and I added as quivers the variation of variations
Script here : https://gist.github.com/jul/0f16782ed01f18c2c72a

Here are the results :
First order Takens for GE opening prices are swirling in the negative sense

Nice vortexes :)
2000 Random int between 0,32. The fadest, the oldest data.
Another point of view of on randint


Takens series were once used in an article to make an analysis of the randomness of TCP/IP and the impact of PRNG lack of randomness.

This article is a good introduction to how to use this tool on sampling randomness : http://lcamtuf.coredump.cx/oldtcp/tcpseq.html

I also got confirmation some regulations office are using Takens series to see if people are cheating online :)


Complex systems are both resistant to perturbations and unpredictable. A lot of phenomenons are like these: simple in their understanding but made of a lot of elements interacting: weather, the movements of the stars, your heart .... our IT infrastructures.

Takens series can be tweaked in more than one ways :)

Addendum: I used the periodic boundary conditions as a former physicist, because it does not essentially alter the result, and it makes code more readable even if incorrect for 4 points.
Why using 5 offsets? Every time I make a derivation I consume one degree of freedom.
so 3 dimensions + 2 derivations = 5 offsets. As a result it means by playing funnily I can devise as much space phases I have elements in the time series per dimensions minus the order of derivative I want to display.

PS : I forgot to seed the PRNG so that we can "see" the same things. Random data being random, without  seeding then results will differ normally according to the seed.

Viewing all articles
Browse latest Browse all 22462

Trending Articles