Monday, May 21, 2012

Viral Storm



Book Review : The Viral Storm
Author : Nathan Wolfe
My Rating : 3 out of 5

The complete title of the book is "The Viral Storm: The Dawn of a New Pandemic Age".

I came to know about this book from "The Colbert Report" when the author Nathan Wolfe was interviewed. He boasts an impressive resume. He was previously a tenured professor at UCLA, now he is a professor at Stanford, has published numerous papers with many years of field research in remote parts of the world. He is more than qualified to write a book on this topic.

The world of microbes is fascinating but largely ignored by anyone who is not in medical field. There aren't as many PBS Nature shows on them as there are on other species. We talk about them only when there is an outbreak. But for Nathan Wolfe, this microscopic world has been a lifelong obsession. He started out as a researcher, and now heads the unique efforts of a not-for-profit organization called Global Viral Forecasting Initiative.

The idea behind such an organization is very interesting and is explained at the very end of the book - how to predict (and prevent) future outbreaks. Their tool-set is diverse and innovative. It even includes analyzing Google search patterns and trending topics on Twitter. But what is a pandemic ? How does it start ? How does it spread ?

Nathan Wolfe argues that understanding these questions is important because it's almost certain that there will be new pandemics and new lethal viruses. To explain that, he starts from the very beginning, at the dawn of human evolution, when our primate ancestors ventured out of the forest into the savannah. The microbes have been evolving with us, and continue to evolve like any other life form.

For any virus that wants to affect as many hosts as possible, there should be means to spread. We are not just a super connected world with fast means of mass transportation. As the author puts it, we are also an "intimately connected" world, where blood transfusion and organ implants give new avenues for the viruses to spread.

There are many such insights in the book. Now I know, this cannot be a relaxing discussion. So the author tries hard to be an optimist and not an alarmist. He obviously is passionate about the topic and is at the forefront of preventive efforts. That passion comes through.

But it's not as satisfying as I hoped it would be. Often times it feels like a book about "who's who" of the "virus hunters", and less about explaining scientific ideas to outsiders. The researchers deserve credit, but it would be nice to learn more about the topic they are researching. Hence, it feels like written by an executive and less by a scientist. I wish he had spent more of the pages on explaining more about the biology concepts related to the discussion. If advanced topics in math and physics can be explained to laymen, I am pretty sure it's possible for biology as well.

I can still recommend it, because it's a worthwhile reading about a field we rarely hear about.

Friday, May 4, 2012

Julie and Julia

Movie Review : Julie and Julia
Director : Nora Ephron
Genre : Drama
Starring : Meryl Streep, Amy Adams, Stanley Tucci, Chris Messina
Released : 2009
My Rating : 6 out of 10

Anyone who has any interest in cooking has heard of Julia Child. Her first book "Mastering The Art Of French Cooking" was released in 1961, and it created culinary revolution by making fine French cooking easily accessible to American households. Still widely available, and universally loved, it is a true classic. Subsequent TV show, "The French Chef" confirmed her as the American Cooking Icon. (To be honest, I have read those 20 pages of detailed description on how to make an omelet, and I still cannot make a good French Omelet. But that's hardly Julia's fault.)

In 2002, a Queens resident Julie Powell. decided to cook all the 524 recipes in this classic in a year, and blog her daily experiences. She needed a distraction from a stressful job and her husband suggested this idea because of her love for cooking. This blog became popular, and Julie Powell wrote a book about that one year in her life.

That book is the inspiration for "Julie and Julia". It examines the lives of both women. They never met in person, so the movie flips back and forth between the two stories from two different periods. Sometimes, these switches work, sometimes they seem forced.

There are some interesting situations and funny moments. I didn't know that Julia Child took to cooking because she didn't have much to do while her diplomat husband was stationed in Paris. She tried different classes - including bridge, but eventually joined a cooking class, because she loved French food. She wasn't readily accepted, but she persevered. Her struggles and subsequent successes give a good insight into her personality.

These occasional moments fail to cover the movie's flaws. Neither story is particularly exceptional and to stick to the theme - both are a bit bland. Not all life-stories are eventful, and in such cases, the script writers have to rise to the challenge of making them engaging. In this movie that didn't happen, hence it feels long and drawn out.

I am a fan of Meryl Streep, but her acting in this movie felt very unnatural. I know she was trying to sound like Julia Child, but it was so forced and monotonous, that it became a bit irritating. Amy Adams did her best, and she succeeds in being cute most of the time. The problem is, her character is selfish and not really that likeable.

Overall, I was not too impressed with this movie. And I love cooking. It's an above average movie, and if you don't have too high expectations, you might like it. It's correctly rated PG-13, but kids will be frankly bored.

Tuesday, May 1, 2012

Generating Prime Numbers Using Sieve of Eratosthenes

Generating a prime is occasionally needed in solving coding puzzles. It's a pretty straightforward task, whether you stick with a naive brute force solution or with "Sieve of Eratosthenes". I am going to use this one later to show a solution for a more involved problem.

The "Sieve of Eratosthenes" is a very old method of generating the primes, named after an ancient Greek Mathematician who invented it. It's intuitive to understand, and efficient.

You start with number 2, and mark all numbers up to N that are divisible by 2 as non-prime, by just hopping forward 2 places, till you reach N. Then you start with 3, and mark every third number as non-prime. Next number 4 is already marked as non-prime, so ignore it. Then start with 5, and mark every 5th number as non-prime. And so on.

A simple observation helps most algorithms related to checking/generating prime numbers.
For finding a factor of any number N, you only have to check using numbers that are less than the square root of N. Because if N = x * y, and x > sqrt(N), then it must be true that y < sqrt(N).
You can use this observations is 2 ways.
1. When you are considering the factors to cross out the composites, you need to consider factors only till sqrt(N).
2. When you start crossing out, you can start crossing out numbers from factor^2. Anything composite below that would be a smaller multiple of factor, and would have been crossed out.
Here is the Java code :

// consider all numbers as prime to begin with
// init array of N flags to false
boolean is_non_prime[] = new boolean [N+1] ;
// NOTE : first index is 0

is_non_prime [0] = is_non_prime [1] = true ;
// 0 and 1 are not considered primes

for (int factor = 2 ; factor*factor <= N ; factor ++) {
    // no need to find composites of a non-prime number
    if ( is_non_prime[factor] )
        continue ;

    for ( int composite = factor * factor ;
              composite <= N ; composite += factor ) {
        is_non_prime [composite] = true ;
    } //
} //

After this, the array is_non_prime[k] = false for any number K that is prime.

Of course, this needs memory of N bits for storing the flags, which is not an issue in most applications.

Finding the computational complexity is a bit tricky. There are 2 loops, but the complexity is not O(N^2). The outer loop is executed K times, where K=sqrt(N). The inner loop executed only for primes, which is significantly less than K for large values of K.

Note that for factor = 2, there are N/2 operations because N/2 numbers will be crossed out. Then for factor = 3, there will be N/3 operations. Then N/5 operations and so on. So
Total operations = N/2 + N/3 + N/5 + N/7 + N/11 + N/13 + ...
  = N * ( 1/2 + 1/3 + 1/5 + 1/7 + 1/11 + 1/13 + ... )
The term in the parenthesis is "prime harmonic series" . It has been shown to have the upper bound of ln ln (N). Where ln is the natural logarithm, and yes, it's a double logarithm : log of log of N.

This means the complexity of our algorithm is O (N * ln ln N ).

The double logarithm make the second term quite small than N. That makes the computation complexity of "Sieve of Eratosthenes" almost linear, which is quite a feat.
Related Posts Plugin for WordPress, Blogger...