Friday, September 11, 2009

A Random Idea in Rags..! :)

Using Randomness to Achieve a Controllable Behaviour..?! :)


It so happened, that, yesterday evening, out-of-the-blue... my dear friend & colleague Krishna Melkote asked me if we could design a kind of
throttling algorithm, without having to worry about state-information ( such as a COUNT of how many requests have been let-through, etc..)..

He wanted the ONLY piece of state to be the "throttle-factor"..!!

Me moron..did NOT get his point..! :-(

But thankfully, he went on to patiently explain with an example that if say, this factor is 70, then it should in effect,"let-through" ONLY about 70% of the requests, & "
block" the rest..!

But this, he wanted to achieve without having a count of the number of requests that have been let-in, queue-ing them up somewhere, etc..!

This led me into wondering about the use of Random-numbers...& arranging stuff such that we obtain a component, whose ONLY responses are from the set {YES,NO} ....(or {TRUE, FALSE} or whatever u want..! :) )...but it should say YES/TRUE, roughly t% of the time, where, t=throttling factor... an integer in the closed-interval of [0,100]

And when i casually simplified it in my funny style & discussed it with Rasna, another very good friend of mine, she suggested a very simple (fer her ! Though me-MORON took a minute to see her point..!! :)) method...which turned out to be a very beautiful algorithm that surprisingly ( For me..! :) ) seemed to take care of all the boundary conditions..!!
{ i.e., when t=0(ALL NO/FALSE) &/or t=100(ALL YES/TRUE) }

Basically, the algorithm (
algoP()) uses an array which has t% of YES/TRUE, & the rest as NO/FALSE...So, assuming we now index into this array with truly-genuine RANDOMness(!?! :) ), we must have a t% chance of being let-through..!! :)

But as it always turns out, me-MORON had goofed up implementing that algorithm, & that forced me to also go through with my algorithm, which does NOT make use of any extra-storage/structures...but somehow, manages to DO the Same task..! :)


PLEASE Click here for the CODE--try it with boundary conditions & switch between algoRags( ) & algoP( )...!! :)

the application where i Have shared code... is a cool Ruby-on-Rails app..! :) This episode, has really made me CRAZY about the queer phenomenon of Randomness..??
  • WHAT is meant by a Random-sequence..?
  • Is Randomness ALL/ONLY in the Mind..?(Like most of the things..?! hehehe..! :)) i.e., if I cannot Predict a given sequence's future..then, is it truly Random ??( or jusst being too complex-ly Computed OLL our Congruence-modulo Linear or Quadratic Pseudo-random Number generators..?!? :) )

That is a very interesting thing to ponder over..!!

Anyway, what a RANDOM thing that me stumbled upon this problem & somehow managed to do something about it too..
!?!?!(with sheer Random-ness !! hehehe)

Ha ha ha ha ! :)))

THANK s a LoT to ALL my Dear ones for bearing with me..& also helping me..! :)

With Lots of LOVE & Thank & Cheers..

(Not!?!?!?! :)) Random-ly yours...

The boy in "rags"

Finally, to Cheer-u-UP...& make you RELAXED..

Here's a superb, naughty
Garfield make you SMiLe...fer a WhiLe..! ;) :)
Me reeeeally Loove it, essp Poor Jon-Arbuckle.. :)

No comments:

Post a Comment

Pleeze do give me YOUr (in)valuable feedback...!
Thanks a lot in deed.. :)