May 31, 2015

Book Review: Predicitve Analytics

According to Wikipedia, predictive analytics is an area of data mining that deals with extracting information from data and using it to predict trends and behavior patterns. Often the unknown event of interest is in the future, but predictive analytics can be applied to any type of unknown whether it be in the past, present or future.
If you have ever bought a book on Amazon, at the bottom of the page you will see the small text "Customers Who Bought This Item Also Bought..." If you for example buy the book Predictive Analytics: The Power to Predict Who Will Click, Buy, Lie, or Die by Eric Siegel, you will see that Amazon recommends to you the books:
  • Data science for business
  • Competing on analytics
  • Predictive analytics for dummies
This is predictive analytics when Amazon's engineers are using algorithms to try to determine which books you might be interested in to read. And this is really working. This is an excerpt from the book The Everything Store of what happened when installed a predictive analytics system: 
Eric Benson took about two weeks to construct a preliminary version that grouped together customers who had similar purchasing histories and then found books that appealed to the people in each group. That feature, called Similarities, immediately yielded a noticeable uptick in sales and allowed Amazon to point customers toward books that they might not otherwise have found. Greg Linded, and engineer who worked on the project, recalls [Jeff] Bezos coming into his office, getting downed on his hand and knees, and joking, "I'm not worthy."
I myself have used predictive analytics a few times before. When I participated in a Kaggle competition to predict if a sound file included the sound made by a whale, I used so called random forests to make that prediction. I've also at the bottom of each article in this blog used predictive analytics to, in a similar way as Amazon recommends books, used algorithms to predict related blog posts.
To learn more about predictive analytics I decided to read the book Predictive Analytics. This book will tell you why you need predictive analytics and what you can do with it, not how. So you will not find a single mathematical equation in the book, but the author will describe some basic algorithms, such as decision trees.
The books if filled with examples from the author's own work within the field and what other people have predicted. One chapter is about the machine that learned how to predict Jeopardy answers. Other chapters include examples how you can predict which employees will quit their job, where a crime might happen, and how Barack Obama used predictive analytics to win an election.
If you, like I have been, involved within the field, you will be familiar with most examples. I've heard before about the Jeopardy machine and the large US retail chain that messed up by sending discounted prices to a teen who they had predicted was pregnant. Her father thought it was an outrageous accusation, and then it turned out she was really pregnant, but she hadn't told her father about it. But if you read through the book and recognize everything, then it will confirm that you know what you should know within the field, and you can move on to applying the algorithms. And if you learn something new, then it's just great.

May 25, 2015

How to optimize Unity and other tips and tricks as well as best practices

This was a link roundup with articles describing how to optimize Unity as well as other tips and tricks and best practices. It has moved to here: Learn how to optimize your Unity project.

May 24, 2015

How to create water wakes in Unity?

The question is: How do you create water wakes in Unity? If you have ever seen a boat on a lake, you notice that it will leave small waves behind it while it is floating forward. But how do you create those waves, and how do you combine them with a moving sea in a computer environment like Unity? I've earlier made a boat that will float in Unity with realistic buoyancy, and now I felt I wanted to learn how to add water wakes. No boat is complete without them.
The answer to the question is using an algorithm called iWave. There are other alternatives, but I believe iWave is the most popular algorithm. It was first published in 2008 in a report called Simulation of Interactive Surface Waves. The report was written by Jerry Tessendorf, who is an expert in the field. If you've ever seen a computer animated sea in a movie, like the sea in Titanic, the algorithm behind the realistic moving sea was written by Jerry Tessendorf.
The algorithm itself is not that easy to understand, but the simplified version is actually very easy to implement - and it is super fast. The only expert tip I have is to change the parameter alpha if you encounter gigantic waves. The algorithm itself is not that stable, so alpha is like a damping parameter. 
My final results look like this:

You can interact with the surface with your mouse, and the small cube will float with my old buoyancy algorithm. The difference now is that the cube will leave ripples whenever it is bouncing up and down. 
Looks interesting? Don't worry, because I will soon write a tutorial on how to do it in Unity. It will be published here: Tutorial on how to make a boat in Unity.  

May 18, 2015

Book review: The Quest for Artificial Intelligence


This weekend I've watched two movies about smart robots. The first was called Chappie and it tells the story of a robot named Chappie, who is the first robot with the ability to think and feel for himself. Chappie is therefore much smarter than any other human. The second movie, Ex Machina, is also about a smart robot with the same abilities as Chappie, although the robot in Ex Machina is looking more like a real human.
The question is how realistic are those movies? Will we soon see robots that are as smart as Chappie? To be able to answer that question, we have to take a look at the history of artificial intelligence, or AI. And that's why I read the book The Quest for Artificial Intelligence by Nils Nilsson.

The Quest for Artificial Intelligence was published in 2010, and is therefore up to date with the latest histories of artificial intelligence. But AI is a field that these days is moving fast, so some of the latest achievements are not included, such as the algorithm that learned how to play the game Breakout.
Nils Nilsson knows what he is talking about. Among other projects, he has developed the famous A* search algorithm. If you have ever played a computer game where the characters are controlled by the computer, the game is probably using the A* algorithm to help the characters find their way around the map.
The early history of AI begins hundreds of years ago when the old Greeks dreamed about self-propelled chairs. Then it continues with Leonardo da Vinci, who in 1495 sketched designs for a humanoid robot in the form of a medieval knight, and ends with a mechanical duck.
But the real history of true artificial intelligence begins after the Second World War, with a series of meetings. At these meetings, researchers described early attempts to highlight features in images and how to program a computer to play chess. The first meeting was called "Session on Learning Machines," so the word artificial intelligence was not yet invented, until someone suggested the word. Everyone were not convinced, but then most researchers began to use the name artificial intelligence. 
"So cherish the name artificial intelligence. It is a good name. Like all names of scientific fields, it will grow to become exactly what its field comes to mean."
What happened after these early meetings was that the quest for artificial intelligence began at the same times as the computers improved. But everything didn't go smoothly. Nils Nilsson has named the downs in the quest for artificial intelligence "AI winters." What happened was that governments around the world sponsored researchers to develop AI algorithms (generally for military purposes). But since AI is a difficult topic, these algorithms didn't always work.
When they didn't work, the governments decided to decrease the funding, and the researchers had to endure an AI winter with little or no money. Then the computers and algorithms improved, the governments were yet again excited, then the algorithms didn't work as promised, and another AI winter happened.
According to Nils Nilsson, what these AI winters led to was scared researchers. The naysayers around the researchers could give comments like:
"Most people working on speech recognition were acting like mad scientists and untrustworthy engineers." 
So the researchers decided to develop simple algorithms that would actually work as promised, and ignore the more complicated algorithms that didn't always work as promised. For example, the transcription of spoken sentences to their textual equivalents is now largely a solved problem. But that is not true intelligence. The computer can't still understand natural language speech (or text) so someone can have a dialog with a computer, like in the movie Her. The latter is generally called strong AI, while the former is called weak AI. So most researchers have throughout history focused on weak AI to not lose any respect. They were saying:
"AI used to be criticized for its flossiness. Now that we have made solid progress, lets us not risk losing our respectability,"
So if you are wondering why artificial intelligence is not as intelligent as in the movies Chappie, Ex Machina, and Her, the answer is that most researchers have focused on weak AI. The emphasis has been on using AI to help humans rather than to replace them. Yes, a computer can beat a human in a game of chess, but that computer is not intelligent. Deep Blue is considered to be the machine that's the best chess player in the world, but Deep Blue doesn't know that it is playing chess. 
"Does Deep Blue use artificial intelligence? The short answer is no. Earlier computer designs that tried to mimic human thinking weren't very good at it. No formula exists for intuition. ...Deep Blue relies more on computational power and a simpler search and evaluation function."
One idea here is to actually have computer chess tournaments that will admit programs only with severe limits on computation. This would concentrate attention on scientific advances. 
The last chapter in the book is called "The Quest Continues," so artificial intelligence is still far away from being a solved problem. We may have algorithms that know how to drive a car, how to paint a painting indistinguishable from true art, and how to compose music. But we are still far away from robots like Chappie.
This short text is far away from being a summary of the book The Quest for Artificial Intelligence. The 700 pages are filled with facts and anecdotes. But don't worry, even though you will need math to develop AI algorithms, the book includes some math to explain a few algorithms, but it is more a history book than a math book. So if you are interested in the history of AI, then you should read it.

May 16, 2015

How to get more data than what you already have by using data you already have

I've read an article about Andrew Ng called Inside The Mind That Built Google Brain: On Life, Creativity, And Failure. He has earlier worked for Google and is now working for Baidu. At Baidu he's working with speech recognition. To make speech recognition work, you will need a lot of data. One clever way he found to get more data by using data he already had is:
Then one of the things we did was, if we have an audio clip of you saying something, we would take that audio clip of you and add background noise to it, like a clip recorded in a cafe. So we synthesize an audio clip of what you would sound like if you were speaking in a cafe. By synthesizing your voice against lots of backgrounds, we just multiply the amount of data that we have. We use tactics like that to create more data to feed to our machines, to feed to our rocket engines.
The rocket engine he is referring to is the speech recognition algorithm, where data is the fuel that powers the rocket.

May 12, 2015

Random Show Episode 28

A new episode of the Random Show with Kevin Rose (founder of Digg) and Tim Ferriss (author of The 4-Hour Workweek) is out! This is episode 28.

Lessons learned
  • Kevin Rose has begun to move away from the digital world and towards the old-fashioned analog world. Tim Ferriss is following the same way, and he's often putting his phone on airplane-mode to disconnect.
  • Neither Kevin Rose nor Tim Ferriss are interested in Apple's new watch. Neither is Tim Ferriss needing an iPad. He prefers a smart-phone with a large screen and a flat keyboard he can connect to the phone. 

  • Tim Ferriss is experimenting with a new diet (as usual) called Ketosis. To help him, he's using a glucometer called Precision Xtra. 
  • Kevin Rose is drink a lot of coffee (and tea) and now he has bought a coffee bean-roaster, called Fresh Roast SR700. Tim Ferriss, on the other hand, has a Hario V60, which is a Japanese coffee brew method.
  • Kevin Rose has bought a new camera, a Leica M-P, which is a camera that's both digital and analog.
  • Kevin Rose recommended the the Breakaway Matcha, which is a brand of green tea, and he is also into fermenting is own food.
  • Both Tim Ferriss and Kevin Rose are using an egg-cooking-machine called Cuisinart Egg Cooker.
  • Tim Ferriss recommended the book A Wrestling Life: The Inspiring Stories of Dan Gable, which is a biography on the wrestler and coach Dan Gable.
  • The "Tim Ferriss Experiment" is out! It is a video-series where Tim Ferriss is experimenting with various skills, like shooting a gun, learning a language, and driving a rally car.

If you want to watch the rest of the episodes, you can find them here: The Random Show with Kevin Rose and Tim Ferriss.

May 11, 2015

How to tie your running shoes to prevent blisters with a "Heel Lock" or "Lace Lock"

When you are buying new shoes and lacing them for the first time you might have wondered why the upper part of the shoe sometimes have two holes. I've wondered that, but I've never thought about finding out why there are two holes. Today I found a video explaining exactly that. Apparently, if you are using the second hole (in the way described in the video below), it will prevent blisters. This technique is called a "Heel Lock" or "Lace Lock."

May 10, 2015

Book review: I, Robot by Isaac Asimov

Two words everyone in the world should be aware of is technological singularity, which is a moment in time when smart machines become intelligent. If you have seen the movie series Terminator, you know what I'm talking about. In Terminator, this moment is called "judgment day" and is almost the end of mankind. But technological singularity doesn't have to be something bad. What if the smart machines can help us to build a better world? This is what the book I, Robot by Isaac Asimov is all about. 
I, Robot is the first book I've read written by Isaac Asimov. Ever since I wrote a biography on Elon Musk, I've wanted to read one of Isaac Asimov's books because he is one of Elon Musk's favorite authors. But I had to wait until one of my neighbors left I, Robot in our local book club, which is basically a shelf in a window.
The book was first published in 1950 and became a huge success. It has over 148 thousand ratings at Goodreads. That's not strange because the book was very interesting. Elon Musk is also interested in technological singularity, and I've earlier read a few books on the topic
What's interesting with I, Robot is that it covers the development of smart machines, from stupid robots to machines that can build other machines. It will also look at some of the pitfalls that might happen when we develop them.
I, Robot consists of several smaller stories that are somewhat connected, although you can read them independently. The first story is about a robot designed to take care of a girl and what people in general might think of a smart robot. Other stories in the book is based on the Three Laws of Robotics:
  1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.
  2. A robot must obey the orders given it by human beings, except where such orders would conflict with the First Law.
  3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws.
You might think that mankind is safe if we design the robots to follow these laws. But that's far away from the truth. Machines are both smart and stupid. What happens if a human tells a robot to "go away," meaning that the human just want the robot to move a few meters away from him/her. The robot will follow "A robot must obey the orders given it by human beings," and might interpret "go away" as hiding. This is one of the stories in the book. The "smart" robot hides among other robots and the main characters in the book have to figure out who is the robot that's hiding among the other robots.
These robots are designed by human beings. As we all know, human beings are greedy. What will happen if a human being decides to ignore one the the Three Laws of Robotics? That's another story in the book. And what happens if we tell a robot to build a spaceship? What if a robot becomes so human that's impossible to tell the difference, and that robot decides to become a politician? Will we be able to tell the difference? How can in comparison stupid humans outsmart an intelligent machine?
So if you are interested in what might happen when we have smart robots around or lives, then you should read I, Robot. Isaac Asimov might have written it in the 1950s, but it is still accurate.

May 8, 2015

2015 Update: Peak Oil - Are we there yet?

About a year has passed since we looked at our old oil charts to see if we can see any signs of peak oil. You can see the 2014 version here. Enough talking, let's watch the charts.

The chart above displays the global oil production between 1965 and 2014. The global oil production has actually fallen from 31,682,000,000 barrels to 31,665,210,000 which is a very tiny decline. This small decline may originate from the number of conflicts that have hit several oil producing countries.
The chart that is most interesting to look at is the chart that has to do with the US oil supply. US is after all the world's largest consumer of oil. Also, a few years ago, some analysts argued that US could begin to export more oil than it consumed as a result of the new fracking sources. 

This is how the numbers have changed:
  • The production has increased from 2,737,500,000 to 3,651,095,000 barrels per year
  • The consumption has fallen from 6,898,500,000 to 6,893,755,000 barrels per year
  • The imports have decreased from 2,821,480,000 to 2,677,911,000 barrels per year
  • The exports have increased from 48,968,000 to 126,152,000 barrels per year
So we can see that US is far away from becoming a major exporter of oil. 

May 7, 2015

Book review: The Sell by Fredrik Eklund

Source: @fredrikeklundny
As I promised a few weeks ago, I've read the book The Sell - The secrets of selling anything to anyone by Fredrik Eklund. He's one of the best real-estate agents in New York, and probably the world because New York is the hottest market for real estates. Can you sell in New York, then you can sell everywhere. I've read a few other books on selling, and my goal is to read one new book on selling every year, which was recommended to me by one of the books. 
So this year I read The Sell. The author Fredrik Eklund is Swedish, and so am I, so I knew who he was even before I began reading it. He is not that famous in Sweden, and I believe he is most famous for suddenly begin speaking English during an interview on Swedish television where they began by speaking Swedish. Everyone has made fun of him since then even though it turned out the story was more complicated than that. I will not tell the entire story, but he didn't do it by mistake or that he had somehow forgotten how to speak Swedish. 
Like many other books on selling, The Sell will tell you that all salesmen/women have to be structured, be dedicated to selling, look good, dress well, and both you and the person you are selling something to have to be satisfied after the deal. 
The difference between this book and the other books I've read on selling is that The Sell has been adapted to the Internet age. Fredrik Eklund has included an entire section on how to be popular on social media, like Twitter and Instagram, because those tools are now important. He says that 25 percent of his business originates from social media.
Another large part of the book is dedicated to the person who is selling something. Fredrik Eklund says that you should "forget selling and begin by finding yourself." You have to believe in yourself and accept setbacks. You have to exercise, sleep (Fredrik Eklund is always sleeping for at least 8 hours), and eat healthy food. 
The part of the book that is most different from other books on selling is the part that tells you that you should be you. "If you want people to believe in you and in what you have to offer, you have to believe in yourself." I don't know if you have seen it, but Fredrik Eklund is famous for doing the so-called "high-kick," which is a kick in the air while yelling. He is even doing it in-front of clients, including the famous ones, so that they will remember him. Because selling is always competitive, you have to find a way to stand out. "The crazy and happy ones, not the normal and bitter ones, become the real superstars." Another example is that Fredrik Eklund is telling us to to leave the black funeral-suit at home and dress in something with more color. Fredrik Eklund is often wearing a blue suit.
So if you want to listen to a success story (Swedish guy without any contacts and money becomes a porn star in US and then the top real-estate broker in New York), improve your selling skills, and learn how to improve your life, then you should read The Sell.

May 4, 2015

Book review: The boy who harnessed the wind

I like to watch TED talks. One of my favorite TED talks is about a young man named William Kamkwamba where he's describing how he built a windmill by using only scrap. Here it is:

A few days ago I found out that he had written a book called The boy who harnessed the wind - Creating currents of electricity & hope. The book will not only tell you the story of the windmill, but also how he grew up and other technical projects he had. So the windmill is just a small part of the book.
William Kamkwamba grew up in Malawi, which is a small country in southeast Africa. He grew up in a poor family and he lived in a small hut made of clay. They didn't have electricity, so he had to go to bed at 7 PM when the sun had gone down. The only option they had was to save money and pay the electricity company to install electricity, but they couldn't really afford it. Neither did they want to save the money because the electricity company in Malawi was know for its frequent blackouts.  So what's the point of first save money and then not have any electricity anyway?
When I say that William Kamkwamba grew up in a poor family, were are talking really poor. Like most families in the country, they had to grow corn so they could feed themselves. But when a harvest failed due to bad weather the entire country began to starve.
It fell upon us like the great plagues of Egypt I'd read about, swiftly and without rest. As if overnight, people's bodies began changing into horrible shapes. They were now scattered across the land by the thousands, scavenging the soil like animals. Far from home and away from their families, they began to die.
His family had saved some money, but they had to spend their last savings on food. The school system in Malawi is not entirely funded by taxes, so William Kamkwamba was forced to drop out of school. Because of the famine, only 20 out of 70 students could remain in school. Even the teachers were forced to spend their day searching for food.
Luckily, William Kamkwamba and his family survived the famine. But they couldn't afford his student fees because of a series of unfortunate circumstances, so while his classmates could return to school, William Kamkwamba was forced to remain home. 
But William Kamkwamba wanted to learn what his classmates were learning, so he decided to visit a small library. In the library he found the books Explaining Physics, Using Energy, and Integrated Science, which interested him. He had earlier wanted to learn how car engines worked, but no-one in the village knew, and he had taught himself how to repair radios. As he read the books, he learned more and more and one day he decided to build a windmill. This is how it looked like: 

Source: Moving Windmills

If he could build the windmill, it could rotate a pump for water and irrigation. This could mean that his family would never have to starve again, and he could get electricity for his home. But everything didn't go smooth. At one point, and because of the country's low education level, his neighbors wanted to tear down his windmill. The reason was that they thought it blew away the rain clouds. To not upset anyone, he had to stop the blades during the day.

May 2, 2015

Book review: So, Anyway... by John Cleese

One of my favorite comedians is John Cleese. I don't know how many times I've watched and laughed at Fawlty Towers or Life of Brian. But I haven't really known anything more about him, so I decided to read his biography called So, Anyway... written by himself.
It turns out that John Cleese grew up as the only child in a family with a mother who was a little bit crazy and the family constantly moved around in England. He explained in the book that constant relocation in childhood is often associated with creativity. Your mind will become more flexible and capable of combining thoughts and ideas in new and fresh ways. Another proof that this theory might be the truth is the entrepreneur Elon Musk. His parents divorced when he was young and he moved around the country of South Africa, and is now considered a creative genius. If you want to read more about Elon Musk, you should read my biography book on him called The Engineer - Follow Elon Musk on a journey from South Africa to Mars
But back to John Cleese. If you have watched his movies, it might be difficult to accept that John Cleese was an introvert. He was also a good student who studied at Cambridge and he was also a teacher in science, English, geography, history and Latin. He was smart and got one of the best grades in criminology after just reading the book two days before the exam. 
It was at Cambridge he started practicing comedy. After the exam he decided to pursue a career in comedy instead of law. He said that "very, very few people have any idea what they are talking about," a reference to those who said that he should work with practicing law instead of comedy. In hindsight, it turned out that it was a good decision to not listen to other people.
But the road to fame wasn't always straight. Like other skills, writing and performing comedy is not easy. What John Cleese learned was that when acquiring some skill, we don't improve gradually, like some ascending straight line on a graph; the improvements take place suddenly. After a period of not appearing to get better at all, if we just keep patiently practicing, there will be an unexpected jump up to the next level:

Plateau... jump!
Plateau... jump!

Plateau... jump!

Because writing comedy is difficult, John Cleese delivers several blows aimed at mostly British journalist who tended to sometimes write bad reviews of his shows. He explained that 
British journalists tend to believe that people who become good at something do so because they seek fame and fortune. This is because these are the sole motives of people who become British journalists.
Also, some journalists tend to write bad reviews just to get noticed. This happened after a show in Canada. The audience in Boston liked it, but when John Cleese performed it in Canada, the reviews dismissed it as a dreadful, talent-free disaster. But then someone told him that "the Canadian critics are always like that."
If you happen to be an aspiring comedian, John Cleese's best advice is to steal the idea that you know is good, and try to reproduce it in a setting that you know and understand. 
Comics steal and then conceal their loot. The fact is that it is exceedingly difficult to write really good comedy. Those who can do it possess a very rare talent.
What you also should do is to always try to improve and learn something from each performance. If you are performing the same piece night after night then you can carry out a series of little experiments, discovering what works and what doesn't. Every single night you will learn something new about the psychology of your audience. 
It will always be difficult to learn the psychology of your audience. John Cleese noticed that sometimes his audience started laughing at things no one had ever previously laughed at. Laughter is also infectious, so people tend to laugh together, but when they view the same production separately their opinions will vary more widely. It may also take time before a sketch becomes a classic. It took about five years before the "Dead Parrot" mysteriously morphed into a classic. 
Neither should a comedian try to be a perfectionist. John Cleese learned that when you stop concentrating on avoiding mistakes, you relax a bit, and consequently you will actually make fewer mistakes. The more anxious you feel, the less creative you are.