Implementing Univariate Linear Regression in Python

The objective of this post is to explain the steps I took to implementing univariate linear regression in Python. Do note that I’m not using libraries with inbuilt ML models like sklearn and sci-py here.

Here is our gradient descent function, utilising mean squared error as the cost function.

def gradientDescent(theta, alpha, iterations):
    
    m = ex1data.shape[0]  # finding the number of trial examples
    n = ex1data.shape[1]  # finding the number of features + 1
    
    for iteration in range(iterations):
        
        total0 = 0
        total1 = 0
        
        for row in range(m): # iterating over each training example
        
            hypothesis = 0
            
            for val in range(n-1):
                hypothesis += ex1data.values[row][val] * theta[val][0] 
                
            load = hypothesis - ex1data.values[row][n-1]
            total0 += load*ex1data.values[row][0]
            total1 += load*ex1data.values[row][1]
            
        temp0 = theta[0][0] - ((alpha*total0)/m)
        temp1 = theta[1][0] - ((alpha*total1)/m)
        theta = [[round(temp0, 4)], [round(temp1, 4)]]
        
    return theta

We carry out gradient descent 1500 times here, by setting iterations equal to 1500. Our starting values of theta are 0. Now, for those of you who don’t know how gradient descent works, here’s a short explanation that attempts to cover the crux of it. Intuitively, we subtract each of our output values as given by the hypothesis function by the target value we’re trying to predict, then square the difference. The gradient descent update rule subtracts the partial derivative of this (beyond us mortals for now) from the existing values of theta – updating them. This entire process repeats 1500 times until gradient descent converges to an optimal value of theta, or the minimum point of the cost function.

Now, we plot our data to see what it looks like.

m = ex1data.shape[0]
print ('No. of training examples --> {}'.format(m)) # outputting the number of traning examples for the user
eye = []

for i in range(0,m): 
    eye.append(1)  # creating an array of 1s and adding it to X
    
if len(ex1data.columns) == 2:  # to avoid an error wherein ex1data already has the column of 1s
    ex1data.insert(0, "feature1", eye)
    
print ('here is theta (initial)')
theta = [[0], [0]]
matrix_print(theta)

Now, we firstly add a column vector consisting entirely of 1s, of dimensions m by 1, to our feature matrix. Hence, we have a feature matrix of m by 2, where one column pertains to our variable data and another to a column vector of 1s. We then initialise both values of theta to 0. Our learning rate, alpha, will be set to 0.01 for gradient descent, and we will execute gradient descent 1500 times. After running gradient descent and plotting our predicted values against the actual dataset, this is what we get:

Pretty cool, right?

This entire example was based on solving the Week 1 problem set of Andrew Ng’s machine learning course on coursera.org through Python. So credits to Stanford University. Stay quarantined, stay safe!

Summary of Reading – March ’20

Homo Deus, Yuval Noah Harari – Scary, impactful, dire, and exciting. As Harari clearly stated towards the end, the book outlines probabilities and not prophecies for the future, but each advancement in technology and each step forward in dataism he predicts bifurcates into multiple, significant impacts on us, humankind. The book pens down paths towards everything from extinction events akin to humans wiping out animal populations, to a downfall of liberalism and a completely deskilled society. Being a practitioner of data science, Harari’s message was something that just didn’t have deep implications, but also seemed real enough to be taken seriously. Another thing that stood out for me is Harari’s explanation of capitalism as a distributed data processing system, and how no single person knows the great machine works, but the great machine keeps on working; how politicians are genuinely oblivious to the working of their nations, because the working of their nation is dependant on how everything falls together and how social forces interact. I compared this to the Foundation Saga as well, where individuals play no role in the greater scheme of things, but what Harari predicts is of a much larger magnitude: humans will play no role at all.

Astrophysics for People in a Hurry, Neil deGrasse Tyson – Worth a read. I had a decent idea about the stuff Tyson talks about in this book beforehand, but that didn’t prevent it from being enjoyable. I especially loved the descriptions of various elements in the cosmic sense: where they came from and their role within the universe. His entire commentary on dark matter and dark energy was also catching, especially how the effect of both counter-acts Einstein’s cosmological constant, which I’ve never heard of before. I especially remember Tyson pointing out how Einstein’s greatest blunder wasn’t the cosmological constant, but instead labelling the cosmological constant as his greatest blunder. He doesn’t betray the purpose of his book, delivering the wonder of the cosmos to all audiences, which is unique given how most books of the non-fiction, science genre pretend to be easy to grasp for anyone at all but end up being warped and confusing for most.

Taking a look at the past and the future of Mechanical Engineering.

Arguably humankind’s greatest engineering and technological accomplishment, the Apollo Program landed a human on a body other than planet Earth for the first time. Constructing and using the command and lunar modules was a major engineering feat. As per the Lunar Rendezvous method, the command module remained in orbit (with one occupant), and the lunar module went down and came back up (carrying two astronauts) – an elegant solution. Making the lunar module was a humongous challenge; it needed to be as lightweight as possible without compromising on any of its functions. In the end, NASA engineers ended up removing the seats themselves.

The construction of the Saturn V rocket is another impressive landmark. It burned 15 tons of fuel per second at lift-off, generated 7.5 million tons of thrust, and stood as tall as a third of the Empire State Building.

Personally, I find how NASA used archaic computer systems to process data and monitor the mission, doing everything from calculating trajectories and ensuring constant communication between Houston and the Eagle, pretty awesome. Do note that these computer systems, today, would be less powerful than an Apple Watch.

However, the most significant impact of the Apollo Program deviates hugely from the engineering and technological advancements it made. It showed Humankind an image of the Earth as seen from the Moon. Seeing this pale blue dot from afar, so small that it could be covered with the back of your thumb, had a profound, overbearing impact on people.

Concerning the future, I think the greatest feat of engineering in the next 100 years will be constructing a human colony on planet Mars. Doing so will require the development of means to transport thousands of tons of equipment, materials, and resources (along with humans) to Mars. We’ll need to set up basic infrastructure on Mars, and build habitats/shelters that enable humans to survive the harsh environment of the Red Planet; a thin atmosphere, dangerously high radiation levels, and wildly fluctuating temperatures.

Transporting materials and humans there will require space travel infrastructure. The sheer amount of traffic involved could warrant the construction of the first spaceport outside of planet Earth, on the Moon, from where taking off would be significantly easier due to a weaker gravitational pull. Reusable rockets will be key, so they must endure trips of upto 2 years upto ten times throughout their lifespans.

Providing water, food, and breathable air to future Martians will require technological innovation. Lab-based agriculture will not not be enough to feed an entire population, so alternate sources of food must be developed. Habitats would need to counter wildly fluctuating temperatures by cooling the system during the night, and heating the system during the day. Furthermore, setting up energy infrastructure on Mars will be even more hard. Solar is a viable option, but is rendered ineffective during dust storms. The current alternative, in my opinion, is nuclear fusion, given that the 100 years of progress that take us to a position where we can construct a colony on Mars also give us the means to harness the awesome power of nuclear fusion.

Summary of Reading – February ’20

Talking to Strangers; Malcolm Gladwell – I think Gladwell set the bar too high with Outliers and David and Goliath. Don’t get me wrong, talking to strangers is a wonderful book but it’s in no way as impactful or as relatable as the two aforementioned books. What made outliers stand out is that it resonated with our desire to succeed and be the outlier in a group of people. What made David and Goliath stand out is the simple fact that everyone has faced a ‘Goliath’ per say at some point in their lives. Gladwell’s primary point over the course of the book is that we really don’t know how to talk to strangers, and while that is elaborated on, the book just isn’t as good as outliers. I think this is a textbook case of an author trying to unsuccessfully grow out of his own shadow. Regarding the book itself, it’s definitely an interesting read. The main lesson I took away from it is that I shouldn’t default to truth and trust everyone I talk to on face value, but also shouldn’t assume everyone is something they don’t appear to be. There’s a broad grey area in there, that’s where I should operate socially. Also, another thing I took away is that jumping to conclusions on what is clearly insufficient data isn’t really comprehensive, and mowing down on it will be helpful.

Origin; Dan Brown – The ending destroys the entire book. Brown spends the entire book building up to a huge scientific discovery, over which people have been killed and monarchs have been allegated, but throws all that tension and suspense down the drain with a discovery that fails to honor the time and effort that went into making it look exciting. Brown tries to balance science, religion, and technology, yet fails miserably. The twist at the end that Winston conducted and oversaw everything, especially the assassination of his creator, is pretty harrowing and way more impactful than the premise of the book itself. I also loved Kirsch’s character, everything from how he collected his old PCs to his Tesla publicity stunts and his pure attention-grabbing nature (relatable). Also, the king’s secret, a.k.a, his gay relationship with the bishop seemed like a complete publicity stunt to me, totally redundant and added nothing at all to the story. Seemed like an attempt at creating something that was barely marketable.

Artemis; Andy Weir – Definitely had the same level of complexity as The Martian, but fails to be as impactful. Really suffered from the protagonist giving too many personal anecdotes, which either came off as either funny or jargon. Also suffered from doing stuff that was either over-explained, or totally unnecessary. Artemis is a continuation of that long tradition of authors not being able to grow out of the shadow of their best-sellers. On the other hand, I loved the setting, and the attention to detail when it came to depicting Artemis. That entire union between a purely sci-fi world and the politics that dominates everyday life on modern day planet Earth is beautiful. The effort that goes into preventing Artemis from being entangled into the web that is crime syndicates and gang wars is also commendable.

Ready Player One; Ernest Cline – Hands down one of the best books I’ve ever read. The pure geekiness, the thrill of playing the game, and all that energy throughout the book are contagious. Every little detail, from Parzival’s X-Wing to countless DnD references. The story, in itself, is quite a rollercoaster. Cline takes the simplicity of solving a series of challenges and applies it to an endless virtual world that is the largest economic asset in reality. Countless planets, endless possibilities; everything from playing your way through movies as the lead character, to programming decades-old computers. There’s a subtle commentary, through the inclusion of the IOI, on how excessive regulation and order (being told what to do the entire time) is deplorable, and doing things for the fun of it is many times more rewarding. Definitely the type of book that can get someone hooked onto programming to a greater extent, and heaven for gamers. It played on my inner tech-savvy personality.

Summary of Reading – Dec’19/Jan ’20

A Century is Not Enough (Sourav Ganguly) – Focused primarily on Ganguly’s fighting spirit during his toughest times, and how he got himself to bounce back no matter how low the odds seemed to be. While we do get an interesting snapshot of his cricketing journey, it definitely would’ve been much more exciting had he spent more words on the IPL, or about his life before representing India. What the book conveys, in my opinion, is don’t give up no matter how much you’ve already done, don’t take your position for granted. On a general basis, not that good a book because it focuses solely on the mental aspects of Ganguly’s game, and has sparsely located personal anecdotes and experiences.

Prelude to Foundation (Isaac Asimov) – A step as compared to Foundation’s Edge and Foundation and Earth. What I took away from the initial stages of the book was the contrast between what psychohistory is in the main trilogy, and how unsure Seldon is of it in the book. Really just showed no matter how improbably or irrelevant something seems at the start, its potential really can’t be measured. The different cultures/societies introduced was also fascinating, especially Dahl. What made Dahl stand out, for me, was just how close equality seemed to be, but the irony involved with Dahlites both wanting equality with other sectors across Trantor, and having factions/ranks within their own societal order (no heatsinkers in the house etc.). The ending was also pretty awesome, especially with Hummin being revealed as Demerzel, but then being revealed as Daneel (robot) who was implementing the zeroth law of robotics the entire time. That part where Daneel reveals who also has another plan he doesn’t want Seldon to know about is also pretty telling, with him obviously referring to Gaia. Really served as the sort of reference that made everything much more connected to the later books (chronological).

The Culture Code (Daniel Coyle) – Not that bad, but not excessively good either. The monotone style of writing made reading the book a tad hard (although a short length rescued it). It was interesting reading about how having techniques that promoted open-mindedness in the form of having the ability to question anything, even the management, was pretty interesting. Some parts were inspirational, not that good a read but still worthy trying, especially if you’re taking a shot at being an effective leader.

Forward the Foundation (Isaac Asimov) – Nearly not as good as Prelude to Foundation. I hated how lonely Seldon became at the end. Plus, I’m not a huge fan of Dors being a robot from the very start. How Seldon’s love “made her human” was pretty emotional, but that reveal was way too forged. Also didn’t like Raych and family moving away, and then Seldon sending Wanda away for her own good. Huge difference between the Seldon here, and the Seldon portrayed in the original Foundation book. Also wanted a closer look at Gaal Dormick. I think the Foundation Saga would’ve been decisively better without the two prequel books, they seem like dead weight to me.

Taking a Look at the Entire Foundation Saga

I finished reading Asimov’s Foundation Saga yesterday, and truth is, it has blown my mind. The sheer number of characters, worlds, plot-lines, and events dotted throughout the entire saga is insane. Science fiction doesn’t get any better than this.

Having a story that spans over half a millennium inadvertently led to tons of characters being introduced and cast away. I think what really stood out for me here is that the individual really is powerless, and effectively irrelevant in the larger scheme of things. What one person does can’t ever impact what larger social and economic forces will eventually do. The best example here is the collapse of the empire’s effort to encircle and besiege the Foundation, regardless of the main characters of the time who tried to play their parts as heroes but later realized they have no position within Seldon’s timeline.

I really wanted Asimov to dive deeper into how psychohistory works. We really don’t know anything, apart from the fact that the prime radiant is the single most important tool available to the Second Foundation, and that it’s a predictive science. The only semblance of ‘work’ we have is people like Yugo Amaryl and Seldon staying locked in their offices almost the entire time (with the story detailing what happens when they’re not working). Another thing that I really didn’t get was the contrast between the Trantor we see at the start of the first Foundation book, and the Trantor we see at the end of the second prequel series book. Foundation started off with depicting Trantor as this colossal metallic world, technologically advanced and densely populated with vibrant civilians. However, the Trantor we see at the end of Forward the Foundation is a bleak, dull world with no semblance of life. A world stumbling in its own steps. In fact, the entire premise of the first book was that the glory of Trantor would be tarnished with time and large forces, but the second prequel presents an already worn out Trantor. Lastly, I really don’t see how the empire’s “slow” disintegration into barbarism takes place over a single lifetime. While the Foundation grows strong over hundreds of years, the entire galactic empire splits apart within a maximum of fifty years. Weird.

However, the entire saga clearly had its highs. I absolutely loved Foundation and Empire and Second Foundation. Here are some of my favorite moments from the entire saga:

  1. Bayta Darell shoots Ebling Mis/Reveals the Mule’s identity – Maybe the most well-executed twist I’ve ever seen in writing. Executed to perfection, such that every single event that occurred before seemed to fall into place and conform to this obvious pattern everyone missed. What struck me even more was the Mule leaving Bayta free of being manipulated by his psychic powers simply because she was the first person in his life who genuinely showed caring for him. Powerful. I think what Asimov meant to convey here was that emotions can play a huge role too in any story. Succeeded to some extent.
  2. The Mule finally conquers Terminus – I really adore the twist that comes with Seldon’s recording being not even remotely close to what’s actually happening. It’s utterly shocking, and after two books which kept Seldon and his psychohistory as the bedrock of the entire story, pretty impactful too. Really just conveys the gravity of the situation, and how big a threat the Mule is.
  3. Seldon’s hearing – Seldon vs Trantor, or rather the Empire is entertaining. It’s a classic play on those science versus politics debates we still have today. Seldon’s assertion of how “Scientific Truth is beyond loyalty or disloyalty” is also pretty chilling.
  4. The Mule’s showdown with the Second Foundation – I enjoyed this entire scene just for the thrill it provided. Psychic powers versus psychic powers was pretty eventful. Really caught my attention. Every person trying to double cross the other and control the situation as per his plan, and every single move turning out to be part in a different person’s setup, so much so that even the reader didn’t know who was who until the Mule was defeated. However, I was a bit shocked by how the Second Foundation sacrificed the people of an entire planet just to defeat the Mule.
  5. The Second Foundation’s location is revealed – I think this is the zenith of the entire saga. Everything really just falls down from here. At this point, everyone is wondering whether the Second Foundation is located at Terminus, Trantor, or another obscure world in an infinitesimally large galaxy. I sort of spoiled it for myself by flipping through the first book, and realizing how Seldon told Gaal Dornick that some would stay behind for another purpose. The part of this entire reveal that really struck me wasn’t the reveal itself, but how Trantor is the place where the “Stars end,” which is quite poetic and somewhat stunning. Brought out some nostalgia as well.
  6. Salvor Hardin subdues Anacreon – Liked this thing simply because of the way Hardin brought an entire empire to its knees using the wonder of science, or rather the dependency of an entire empire on it. A bit like Rick bringing down the value of the galactic currency to null.
  7. Foundation’s Ending – The dialogue about the sun and spear was brilliant. Really put the notion of this ant that the Foundation was at the point facing the mammoth that was the empire, set the tone perfectly for the second book in the series (admittedly this drops off a bit at the start of the second book). I view this entire thing as a giant octopus unfurling its tentacles.

What I loved about the saga was the fact that it explored nearly every facet of human existence, and the sheer quality of science fiction it had. Countless characters; degrading and improving technology; falling and rising galactic empires.

Summary of Reading (November ’19)

Foundation; Isaac Asimov – Perhaps the only sci-fi book I’ve read that is able to depict a stunning future along with capturing human flaws and characteristics so accurately. While there was always the sense that the story was pretty much done and dusted right at the start due to the Seldon Plan, what made this book interesting is the portrayal of just how insignificant most individuals are in the grand scheme of things, yet still have potential to influence larger economic and social forces. The plot takes off with the decay of a galactic empire, a theme that definitely hits home in the modern age. My favorite moment of the book is Seldon’s hearing due to his dire predictions for the empire. It shows how scientific truth and empirical evidence often clash with political opinions and desires, and how the former is ignored amidst bureaucracy. Seldon’s statement of “Scientific truth being beyond loyalty or disloyalty” really did give me goosebumps. I see such reflections throughout the world. Certain leaders ignoring climate change. The flat earth theory (utter bs). Even religion, to a certain extent.

Foundation and Empire; Isaac Asimov – The first half of the book conveys an incredibly interesting message, the threat of mutiny. If a ruler has weak military commanders, his empire won’t grow. However, if a ruler has strong military commanders, the threat of rebellion persuades the ruler to remove those commanders. However, the story really did begin with the arrival of the Mule. Thereafter, it’s impossible to put the book down. Everything really just builds up to the end, wherein we learn that the mysterious Mule has been hiding in plain sights all along. Claimed to be a fear-arousing, dark giant with telekinetic powers, he turns out to be pale, frail clown with psychic abilities and powers of emotional manipulation. For me, it really just goes to show how huge an impact emotions have on us human beings. The Mule was able to forge a kingdom, and almost an empire had it not been for the Second Foundation and Bayta Darell exclusively due to his vast emotional powers that allowed him to make entire populations feel miserable.

Second Foundation; Isaac Asimov – The high point in the Foundation series. What makes this book so riveting is the sheer number of possibilities behind and beyond each and every event. Every occurrence has multiple explanations. Every plan years of planning and perseverance. This book really is about intellectual and mental, or psychic battles, rather than the physical challenges faced earlier. Every character strives to outsmart and improvise. Furthermore, Asimov incorporates various other elements that make everything seem all the more human. For instance, the sacrifice of an entire planet to fool the Mule into thinking he had destroyed the Second Foundation, or maybe sacrificing the life, or rather mind, of a Second Foundationer to trick the Mule into falling into the big trap.

Foundation’s Edge; Isaac Asimov The series really does take a drop from here. The characters are much more boring, and the story-line feels like something done just for the sake of writing a book. Regardless, I did find some aspects interesting, such as the gravitics-based spaceship, and the ‘brain’ of the same. This also loses that ‘foundation’ feel with the entire story revolving around a handful of characters, unlike the other books wherein characters come and go but large economic and social forces remain constant.

Foundation and Earth; Isaac Asimov – I don’t know whether this book is horrible because it just is or because it continues this new character-based storytelling format. The first three books covered upto 150 years each, yet the 4th and 5th ones manage to not even span a decade, and act more like documentaries of Trevize’s journey. The entire purpose of this book is to answer a question raised at the end of the last book, which makes no sense. What is even more damaging is the fact that there is absolutely no focus on both the Foundations, which is supposed to be the purpose behind the entire saga.

r/dailyprogrammer – Yahtzee Upper Section Scoring

Here’s the source.

Description

The game of Yahtzee is played by rolling five 6-sided dice, and scoring the results in a number of ways. You are given a Yahtzee dice roll, represented as a sorted list of 5 integers, each of which is between 1 and 6 inclusive. Your task is to find the maximum possible score for this roll in the upper section of the Yahtzee score card. Here’s what that means.

For the purpose of this challenge, the upper section of Yahtzee gives you six possible ways to score a roll. 1 times the number of 1’s in the roll, 2 times the number of 2’s, 3 times the number of 3’s, and so on up to 6 times the number of 6’s. For instance, consider the roll [2, 3, 5, 5, 6]. If you scored this as 1’s, the score would be 0, since there are no 1’s in the roll. If you scored it as 2’s, the score would be 2, since there’s one 2 in the roll. Scoring the roll in each of the six ways gives you the six possible scores:

0 2 3 0 10 6

The maximum here is 10 (2×5), so your result should be 10.Examples

yahtzee_upper([2, 3, 5, 5, 6]) => 10
yahtzee_upper([1, 1, 1, 1, 3]) => 4
yahtzee_upper([1, 1, 1, 3, 3]) => 6
yahtzee_upper([1, 2, 3, 4, 5]) => 5
yahtzee_upper([6, 6, 6, 6, 6]) => 30

Opional Bonus

Efficiently handle inputs that are unsorted and much larger, both in the number of dice and in the number of sides per die. (For the purpose of this bonus challenge, you want the maximum value of some number k, times the number of times k appears in the input.)

yahtzee_upper(
    [1654, 1654, 50995, 30864, 1654, 50995, 22747, 1654, 1654, 1654, 1654, 1654, 30864, 4868, 1654, 4868, 1654, 30864, 4868, 30864]
) => 123456

Solution

Answering this problem is pretty trivial. All you need to do is a create another list that contains all numbers from 1 through the maximum number in the inputted list. Then multiply each number in the new list by the number of time it appears in the old list using the count function native to python. Here’s how it goes:

def yaht(t):
    return max([t.count(j) * j  for j in [i for i in range(max(t)+1)]])
    
# that's all there is to it!

The Foundation Series

This post is sponsored by sheer excitement. May contain spoilers.

It would be accurate to say that the defining aspect of this brilliant series is how ‘human’ everybody is. Human flaws, intellect, and experiences form every single plotline. Whether be it underestimation sanctioning the Mule’s rise to power, or the outrage at Seldon’s predictions of the collapse of the far-reaching Galactic Empire. Every single facet of this book is page-turning. It has everything, from planets coated in metal to spaceships that sync with the mind. The Foundation Series is a must-read for anyone out there.

What I also love is how absorbing the story is even though it spans a thousand years. Attachments to characters are disbanded. The only thing that does remain constant is the inevitability of psychohistory. This allows Asimov to toy around with dozens of characters, making the book pretty unique. Here are some characters I can recall off the top of my head:

  • Hari Seldon (psychohistorian)
  • Hober Mallow (Trader and later Mayor)
  • Salvor Hardin (First Mayor of the Foundation)
  • The Mule (Mutant with powers of emotional manipulation)
  • Bayta Darell (Civilian who stopped the Mule)
  • Arkady Darell (Played like a doll by the Second Foundation)
  • Golan Trevise (Big decision-maker)
  • Munn Li Compor (Councilman)
  • Bail Channis (unconverted military general)
  • Hann Pritcher (converted military general)
  • Bel Riose (ambitious military general)
  • Janov Pelorat (Historian trying to find Earth)
  • Preem Palmer (First Speaker)
  • Stor Gendibal (Speaker)
  • Ebling Mis (Psychologist)

The number of locations involved is fascinating as well. From planets near the galactic centre to those in the outer rim. From worlds abounding with radioactivity to kingdoms at Star’s End. From isolated global consciousness established by rogue robots to pleasure worlds like Kaglan.

Every action has a consequence. Everything plays a part in the larger scheme. Economic and social forces dictate everything. However, in an interesting twist, the only thing that threatens fate is individual actions. The ability to think, see the truth as it is, not as it should be, hampers the Seldon plan. For me, this is inspiring. After all, it does support the view that even one person can turn the world on its head. The Foundation series makes me appreciate certain qualities I never acknowledged before. It makes me desire the iron will of Salvor Hardin. It makes me search for the mental powers of the Second Foundation within myself. It makes me quest for the genius of Hari Seldon..

It would be foolish to express my awe in a single blog post. Pay up. Read this masterpiece of a series. It will open you to aspects of human nature that pass unnoticed. It advertises fallacies and advocates for morality yet sureness.

Here are some amazing quotes from the series.

“Violence is the last refuge of the incompetent.”

Hari Seldon

“Never let your sense of morals prevent you from doing what is right.”

Salvor Hardin

This one’s pretty chilling. Pretty applicable to the real world as well.

“Scientific truth is beyond loyalty and disloyalty”

Hari Seldon

“It’s always easy to explain the unknown by postulating a superhuman and arbitrary will”

Homir Munn

So true.

“The advance of civilization is an exercise in nothing but the limiting of privacy”

Janov Pelorat

September ’19 – Summary of Reading

Pebble in the Sky; Isaac Asimov – Went from a mundane storyline at the start to a brilliant ending bursting with energy. I found it really hard to read this book at the start, primarily due to the massive amount of time and content Asimov spent on setting up stuff. However, as soon as Schwartz escaped, the book magnificently picked up the pace and had me invorigated right till the end. I think it was interesting to see non-Earth people treating Earth people the same way some humans treat other humans, an eye-opener for me.

I, Robot; Isaac Asimov – A storyline composed out of distinct short stories didn’t look impressive to me before I started reading the book, but I was drastically wrong. I think the definitive quality of this book is the way it represents the future. Furthermore, the sheer amount of advancement that is palpable throughout the book excited me a lot. What I absolutely loved was how human elements were combined with robotics, leading to stuff like robopsychology, cyber-sentience, and paradoxes in reality. The last chapter was a bit boring, but on an overall basis, definitely one of the better books I’ve read.

The Godfather; Mario PuzioA well-written book, full of suspense and dynamics, and successful at creating a constant sense of danger. I enjoyed how Puzio switched from character to character and exploited every possible plotline – inevitably creating contrasts and ironies. Every single action had a consequence. That being said, there were some aspects I didn’t like that much. Luca Brasi’s death really hit me hard, and it seemed pretty avoidable and impossible as well. On an overall basis, one of the better books I’ve read, certainly not the best, but a memorable read nonetheless. Puzio’s repeated emphasis on the allure of maintaining composure and calm, and the foolishness of succumbing to anger and paranoia was one of the more concrete messages that got to me.

Automate The Boring Stuff; Al Sweigart – Nice, enthralling introduction to how the powerful the python language can be when used properly. I especially enjoyed the chapters on working with APIs and web browsers. That being said, as a consequence of the book having already become really old, there are various outdated practices that could prove to be misleading. I also don’t get why there’s so much on manipulating data when the far better alternative of pandas already exists.

The Stars, Like Dust; Isaac Asimov Just amazing. This book incorporated everything from rebellion planets to emotional manipulation, had treachery and plots running beneath pre-existing sub-plots. Every page offered a monumental event, every chapter a higher mountain to climb. The end did seem a bit cringy to me, with a breadcrumb being offered for US politics, but it was nonetheless inspiring. The characters were intricately crafted, and the entire affair of good guys being bad guys and bad guys being good guys had the effect of keeping one on the edge of his/her seat. Perhaps the most brilliant aspect of the book, the thought, and later truth, of the rebellion planet not being in a mysterious nebula but instead in plain sight, and the true nature of the director being hidden away in plain sight as well managed to enthrall me.