Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Decaying code, in it's most literal sense

by quidity (Pilgrim)
on Nov 22, 2000 at 03:32 UTC ( #42827=CUFP: print w/replies, xml ) Need Help??

You really, really, don't want to use this, but it's fun. Unless of course you get paid by the hour and feel the need to add a subtle new bug to your code.

::Analytical will decay as though it is a collection of a large number of particles, so could represent the rate of emmissions from a sample say. ::Discreet will decay as though it is a single particle, and obeys the 'if you look you alter things' principle.

::Analytical was written by someone else, but had a bug which is fixed in this version, ::Discreet is all mine.

my $half_life = 5; # seconds my $foo; tie $foo, 'Radioactive::Decay::Analytical', $half_life; $foo = 100; for (1..10) {print $foo,"\n"; sleep(2)} tie $foo, 'Radioactive::Decay::Discreet', $half_life; $foo = 100; for (1..10) {print $foo,"\n"; sleep(2)} package Radioactive::Decay::Analytical; sub TIESCALAR { bless [0,log(2)/$_[1],0], $_[0]; } sub STORE { $_[0]->[2] = time; $_[0]->[0] = $_[1] } sub FETCH { $_[0]->[0] * exp(-$_[0]->[1] * (time - $_[0]->[2])) } package Radioactive::Decay::Discreet; sub TIESCALAR { bless [0,log(2)/$_[1],0], $_[0]} sub STORE {$_[0]->[2] = time; $_[0]->[0] = $_[1]} sub FETCH { if (rand() < (1-exp(-$_[0]->[1] * (time-$_[0]->[2])))) + {$_[0]->[0] = 0} else {$_[0]->[2] = time} $_[0]->[0];}

There are slight problems with this (the model departing from physical reality), in that the time resolution is very limited, if you want to avoid this you need to keep it running for a long time, increase the half life and check the particle less often...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://42827]
Approved by root
help
Chatterbox?
[1nickt]: hm, what did I do wrong? No download link in a code secrtion of a node I just posted ...
[Corion]: I see a download link there?
[Corion]: (at least the curl stuff is in a download link)
[Corion]: Also, I think the OPs problem is on their intranet and not on the internet (also, they should likely use WWW::Mechanize instead, which knows about cookie)
[1nickt]: yes, could be.
[1nickt]: I don;t see the link , definitely, after reloading the node
[1nickt]: Is it possible to disable it?
[Discipulus]: if you mean [download] after the code it is there 1nickt
[1nickt]: yes, Corion sees it too, and I see it when not logged in.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2017-05-23 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?