
– Pradeep

– Pradeep
“Out of the night that covers me,
Black as the pit from pole to pole,
I thank whatever gods may be
For my unconquerable soul.
In the fell clutch of circumstance
I have not winced nor cried aloud.
Under the bludgeonings of chance
My head is bloody, but unbowed.
Beyond this place of wrath and tears
Looms but the Horror of the shade,
And yet the menace of the years
Finds, and shall find me, unafraid.
It matters not how strait the gate,
How charged with punishments the scroll,
I am the master of my fate,
I am the captain of my soul.”
– William Ernest Henley
I had this crazy thought when I was a kid.
“Before I die, is it possible to cover every piece of land on this planet just by walking?”
Let’s do a rough math.
If you consider only the landmass, it is 148.94 million sq km. Consider a 1 sq m bounding box. Let’s assume that this box represents our position and moves at 1 sq m per second. Ignore constraints like sleep, food, and crossing the ocean.
To cover the entire landmass, it would take us approximately 4722.85 millenia 😦

– Pradeep
Source :
https://www.cia.gov/library/publications/the-world-factbook/geos/print_xx.html
Visualization : Inspired by the following links
1. http://maxberggren.se/2014/11/27/model-of-a-zombie-outbreak/
2. https://github.com/Zulko/moviepy
With all the buzz around machine learning, I find new job titles popping up everyday. I’m curious to know how this has affected the job landscape – what new jobs it has created, and what existing jobs require machine learning as an additional skill.
Let’s scrape a job portal to understand.
To keep it simple, I’m scraping a single website with jobs containing the keyword “Machine Learning” in nine big cities of Germany – Berlin, Frankfurt-Mainz, Hamburg, Munich, Stuttgart, Cologne, Dresden, Hanover, Dusseldorf.
I have summarized the results in word clouds comprised of cities, job positions, and major companies involved in machine learning.
– Pradeep

ProTip : Don’t watch Mandelbrot Set infinite zoom video on VR headset for more than 15 minutes.
– Pradeep
References :
1. https://www.ibm.com/developerworks/community/blogs/jfp/entry/How_To_Compute_Mandelbrodt_Set_Quickly?lang=en
2. https://gist.github.com/thr0wn/f80eb02b3e25742aece046f075bb0370

– Pradeep

Approximated using Monte Carlo method.
– Pradeep
I remember this problem from a movie.
“Twenty random cards are placed in a row, all face down. A move consists of turning a face down card, face up and turning over the card immediately to the right. Show that no matter what the choice of card to turn, this sequence of moves must terminate.”
Solution :
Consider each face down card as a 1 and each face up card as a 0. Initially, your sequence will be 11111111111111111111. Following the rule, each move will create a sequence whose binary value will be lower than the previous sequence. Eventually, all the cards will be facing up.
Let’s do a quick check in Python to verify this logic.
import random
import matplotlib.pyplot as plt
Create a list of 20 1s.
L = [1]*20
L : [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Copy this list so that the original list is undisturbed.
I = L[:]
I : [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Let’s formulate the problem and check if it’s working.
for _ in range(10):
idx = [i for i, x in enumerate(I) if x != 0]
N = random.choice(idx)
if N != 19:
I[N], I[N+1] = 0, 1 - I[N+1]
print(I)
else:
I[N] = 0
print(I)
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1]
[1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1]
[1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1]
[1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1]
[1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1]
[1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0]
[1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0]
[1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0]
Now this seems to work. Let’s run this till it terminates.
C = 0
S = [20]
while sum(I)!= 0:
idx = [i for i, x in enumerate(I) if x != 0]
N = random.choice(idx)
if N != 19:
C += 1
I[N], I[N+1] = 0, 1 - I[N+1]
S.append(sum(I))
else:
C += 1
I[N] = 0
S.append(sum(I))
print(C)
print(L)
print(I)
40
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Let’s plot the convergence.
plt.rcParams["figure.figsize"] = [16,9]
plt.grid()
plt.plot(S,'r^-')
plt.title('Convergence')
plt.xlabel('Moves')
plt.ylabel('Number of Face Down Cards')
plt.xlim(0, 60)
plt.ylim(0, 20)
plt.show()

This took 40 moves. In the end, there are no face down cards.
When the same approach was repeated for 100 trials, on an average, it took 42 moves to converge.
– Pradeep
Show me the output of a perfect code
So many lines for the broken code
It’s hard to see in a dark background
So hard to read
Debug with me
Nights of coffee so soon become
Empty and dry I could feel the cooling fan
Your every line will be debugged
They tell me
Show me the output of a perfect code
Is this the program I need to walk with?
Tell me why I can’t see
There’s something missing in my code
Lines go on as they never end
Eyes of hawk observe the trends
They never say forever gaze upon me
Guilty roads to an endless debugging
There’s no control
Are you with me now?
Your every line will be debugged
They tell me
Show me the output of a perfect code
Is this the program I need to walk with?
Tell me why I can’t see
There’s something missing in my code
There’s no one to seek help
I have no place to go
Surrender my heart, body, and soul to stack overflow
How can it be
You’re asking me
To feel the things you never show
You are missing in my code
Tell me why I can’t see
Show me the output of a perfect code
Is this the program I need to walk with?
Tell me why I can’t see
There’s something missing in my code
Show me the output of a perfect code
Is this the program I need to walk with?
Tell me why I can’t see
There’s something missing in my code
– Pradeep
Source :
Original Song : ‘Show Me the Meaning of Being Lonely’ by Backstreet Boys
One of my favourite philosophies.
The following lines are taken from Nirvana Shatakam by Adi Shankara. It attempts to describe the nature of God. If God exists, what will be his/her/it’s attributes. This also addresses the question of ‘What lies beyond all this reality?’
This uses the concept of nothingness and eternal bliss to answer such questions.
This should not be confused with nihilism.
“I am not the mind, the intellect, the ego or the memory,
I am not the ears, the skin, the nose or the eyes,
I am not space, not earth, not fire, water or wind,
I am the form of consciousness and bliss,
I am the eternal Shiva.
I am not the breath, nor the five elements,
I am not matter, nor the 5 sheaths of consciousness
Nor am I the speech, the hands, or the feet,
I am the form of consciousness and bliss,
I am the eternal Shiva.
There is no like or dislike in me, no greed or delusion,
I know not pride or jealousy,
I have no duty, no desire for wealth, lust or liberation,
I am the form of consciousness and bliss,
I am the eternal Shiva.
No virtue or vice, no pleasure or pain,
I need no mantras, no pilgrimage, no scriptures or rituals,
I am not the experienced, nor the experience itself,
I am the form of consciousness and bliss,
I am the eternal Shiva.
I have no fear of death, no caste or creed,
I have no father, no mother, for I was never born,
I am not a relative, nor a friend, nor a teacher nor a student,
I am the form of consciousness and bliss,
I am the eternal Shiva.
I am devoid of duality, my form is formlessness,
I exist everywhere, pervading all senses,
I am neither attached, neither free nor captive,
I am the form of consciousness and bliss,
I am the eternal Shiva.”
– Adi Shankara
Personally, I have never realized ‘True Nothingness’ and ‘Eternal Bliss’.
Is that possible? Even if you have broken the shackles of reality, when you think you have attained nothingness or eternal bliss, your thoughts still exist.
Sometime ago, a friend of mine pulled me into the debate of whether thoughts create the thinker or the thinker creates thoughts. The result was inconclusive.
When a life exists, it manifests in a body. The mind inside the body creates thoughts, and the thoughts in turn give an identity to the body and surroundings. It doesn’t matter what creates what. As long as there are thoughts spread out as waves, there is no true nothingness.
To me, the one who has attained true nothingness and eternal bliss will no longer be in contact with any life form.
Neither he/she will be aware of their existence as a life form.
Sources :
1. http://www.sankaracharya.org/nirvana_shatkam.php
2. https://en.wikipedia.org/wiki/Atma_Shatkam
Image Source :