Data vs. Deadly Stampedes

1.14.2019   |

There is a festival in India so amazing that millions of people attend every year – despite the near certainty that many will die. Nilay Kulkarni grew up hearing the horror stories of human stampedes that claimed hundreds of lives annually.

With a desire to prevent what seemed inevitable, the guiding voice of his grandfather, a hackathon, and a set of black rubber mats, Kulkarni took on human stampedes. This episode of ‘Fixed That For You’ combines the science of crowd control with the power of a lifesaving DIY data collection tool.

Show Notes

Nilay is the co-founder and CTO of Ashioto, a real-time crowd flow analysis platform.

Check out more about Kumbh Mula, one of the biggest festivals in India.

Curious to learn more about crowd safety? Keith Still is a professor of Crowd Science at Manchester Metropolitan Univerisity.

Build something with your own Arduino board.


Nilay Kulkarni: He said, "There will be this festival called Kumbh Mela in six years. There will be a lot of people and some of them will most probably die." It was very sad because we were normalizing death. Honestly, I just wanted to run away from the city, but then I thought I must do something for this, something to solve this.

Cara Santa Maria: Welcome to Fixed That For You, an original podcast from Segment about solving problems with data and algorithms. I'm Cara Santa Maria, a science journalist who's fascinated by the problem-solving process of engineers and developers. In this episode, we're going to look at the science of crowd control through the story of an Indian teenager who invented a DIY data collection tool so he could prevent deadly human stampedes.

Cara Santa Maria: This is the party you've probably never been invited to.

Nilay Kulkarni: It is believed that bathing in the river during this season cleanses you of all your sins.

Cara Santa Maria: It's a Hindu festival called Kumbh Mela, which happens every 12 years in Nashik, a city in India. But here's the thing, people want to go so badly they're willing to risk their lives for it, something Nilay Kulkarni's grandfather told him about when he was just nine years old.

Nilay Kulkarni: It's madness.

Cara Santa Maria: Madness because in a city only built for one and a half million people, the festival attracts 30 million visitors.

Nilay Kulkarni: Most of the times you can't see the street five feet away from you. All you can see is people.

Cara Santa Maria: And this is the problem. Sometimes these huge crowds can spin out of control and anyone that falls down gets trampled.

Keith Still: Imagine you have an egg and you're going to try and push it back into a chicken.

Cara Santa Maria: That's Keith Still. He's a professor of crowd science at Manchester Metropolitan University. Despite the bizarre poultry analogies, Keith is very serious about preventing stampedes. So he's going to help us understand more about the problem.

Keith Still: You get to this position where you've pushed too many people into this space and they start to react in an adverse and unpredictable manner. People start to become anxious. Secondly, with people packed so tightly together, you get this kind of swaying movement, which we call a shockwave. The shockwave is a precursor to a progressive crowd collapse.

Cara Santa Maria: Progressive crowd collapse, that's the technical term for a stampede. But the shockwave and the stampede are results of something that happened long before.

Keith Still: What gave rise to the incident was a lack of understanding that you can't get that number of people through that gap in that period of time or you can't get that number of people into this area. So it's down to planning.

Cara Santa Maria: Planning that requires data.

Keith Still: How many people can move into this area over what period of time? Where are they coming from? Where are they going to, and how long are they going to be there?

Cara Santa Maria: And the chase for the data, that's where Nilay's quest begins.

Cara Santa Maria: It's now been several years since that troubling conversation with his grandfather about Kumbh Mela and the supposedly inevitable stampede deaths. Nilay's a teenager, a precocious 13-year-old.

Nilay Kulkarni: I used to win a lot of computer programming competitions in Nashik.

Cara Santa Maria: With the next Kumbh Mela only two years away, Nilay gets a pretty amazing invitation.

Nilay Kulkarni: I got noticed by a few people who were trying to run this initiative and they said, "Would you like to solve for the Kumbh Mela?"

Cara Santa Maria: He joins a hackathon organized to find solutions to ongoing problems at the upcoming festival, stuff like health, safety, and infrastructure.

Nilay Kulkarni: I said, "Okay, I think this can be my chance of making an impact. I have a real shot at making a difference."

Cara Santa Maria: Nilay's put on a team of engineers in their 20s and remember, he's only 13, working on a plan to stop human stampedes. On the first day, they define what data they need and no surprise, it's the same stuff Keith Still focuses on.

Nilay Kulkarni: We wanted to know, one, the number of people, two, it had to be tied to a location, so the location, and three, it was a derived data point plotting the number of people against time. That would give us the rate at which people were passing.

Cara Santa Maria: That's how many people, where they are, and how fast they're moving. That's his dataset. But the question for Nilay is, how do you get your hands on the data?

Keith Still: I've seen a wide range of video, head counting technology, mobile phone signals, auto fly tags. There's a wide range of technologies that I like to monitor crowd flow.

Cara Santa Maria: Nilay had to figure out if any of those things would work in Nashik, starting with turnstiles.

Nilay Kulkarni: We would have to dig up roads in order to install turnstiles, and there was no guarantee that the roads would stay the same for the next big day.

Cara Santa Maria: He even considered using a laser that would count people passing through a gate.

Nilay Kulkarni: What if you have to count, say, 10 people at a time that are passing shoulder to shoulder?

Cara Santa Maria: That many people would cut off the laser. So Nilay considered high-res photos fed into image analysis software.

Nilay Kulkarni: But we realized that we would need to purchase high-quality cameras. We couldn't just use webcams. That shot up the cost a lot.

Cara Santa Maria: Next on the table were RF tokens, like the ones in your office pass card, but these work at longer range. So they did a cost analysis.

Nilay Kulkarni: Each token at least cost us 40 rupees.

Cara Santa Maria: Okay, that's 50 cents each.

Nilay Kulkarni: Which is impractical if we were to distribute 30 million tags.

Cara Santa Maria: So the team decided to switch gears. Instead of counting the people themselves, they decided to access a dataset that already existed.

Nilay Kulkarni: We thought of using radio towers and using people's mobile phone signals to track them.

Cara Santa Maria: Yeah, something they do to estimate the size of crowds at political rallies here in the US.

Nilay Kulkarni: It sounded so perfect.

Cara Santa Maria: But ...

Nilay Kulkarni: Some North American solutions cannot work in Indian cases. Not a lot of people carry cell phones during Kumbh Mela. They are going there to take a bath. They are going to be in water, so people won't carry cell phones.

Cara Santa Maria: That revelation put them squarely back at step one, and the festival's less than 18 months away.

Cara Santa Maria: Nilay and his team were tackling a problem that involves tens of millions of people, but they have almost no budget and they're running out of time. One day, exhausted from brainstorming, they decide to go outside and take a walk around the hackathon building. That's when one of Nilay's teammates saw something on the ground. It was a decorative strip in the flooring, a different color than the other tiles.

Nilay Kulkarni: The black tiles stood out and people subconsciously were stepping on the tile every time they passed through the door. What if this tile was aware that people were stepping on it? What if the tile could count people?

Cara Santa Maria: Holy crap, that's genius. One step on the tile equals one person.

Nilay Kulkarni: If the tile counts, we can record the data and there we have our solution. That was the aha moment.

Cara Santa Maria: Unlike the earlier ideas, this one seems portable and affordable. But for now, it's just a concept. They've gotta figure out how to build it.

Cara Santa Maria: Nilay's a programmer. His teammates are electrical engineers.

Nilay Kulkarni: They spun up a prototype made out of cardboard and aluminum foil.

Cara Santa Maria: So when someone steps on it, the two pieces of foil touch.

Nilay Kulkarni: They would send a pulse to the Arduino board, which would then count. It was an analog read.

Cara Santa Maria: Okay, an Arduino's an inexpensive circuit board. It uses programmable software so you can write your own code. The team used it to register each individual pulse and then output them as data.

Nilay Kulkarni: It didn't really look like a solution for a problem of such a great magnitude.

Cara Santa Maria: That's true. I mean all it really is is some tinfoil glued to a piece of cardboard with a couple wires connected to an off-the-shelf circuit board.

Nilay Kulkarni: The idea was mostly ridiculed or dismissed.

Cara Santa Maria: Which was unfortunate because this is as far as they got before the first hackathon ended. But for Nilay, his grandfather's words still echoed in his head.

Nilay Kulkarni: There will be a lot of people, and some of them will most probably die.

Cara Santa Maria: It's been several months. Nilay's just gone back for part two of the hackathon. His team improves on their first iteration with a tile made of aluminum composite and foam, pretty much the same concept, but with different components. But it's more durable and more responsive. So they decide to do some real world testing.

Nilay Kulkarni: My uncle owns a restaurant which is quite busy or crowded, so we asked my uncle if we could please sit in the front.

Cara Santa Maria: Nilay was pretty frustrated by the public reaction.

Nilay Kulkarni: Some of them got scared and asked us if they'll get an electric shock if they step on it. Some people did not even ask and jumped over the sensor.

Cara Santa Maria: But his hackathon mentors weren't surprised.

Nilay Kulkarni: They said, "They are not wrong. You can't change their minds in the way they perceive electronics. You have to make it invisible to them. Because what matters is not what you have built, what matters is the problems they face."

Cara Santa Maria: It's one of the core rules of engineering: listen to the user. If they won't step on your mat, it's not their fault, it's yours.

Nilay Kulkarni: This would always stay with me whenever I build a project. The user is never wrong. The technology has to be built around their experiences, around their problems, and we should never stop obsessing over making it even better.

Cara Santa Maria: One of his mentors offered him another crucial piece of advice.

Nilay Kulkarni: He said, "Maybe don't try to build a sensor. Try looking online. If something of this sort already exists, a pressure-activated switch, and maybe just buy that and hack it into your solution."

Cara Santa Maria: In other words, work smarter not harder.

Nilay Kulkarni: We found the perfect solution. It was made out of the stainless steel plates that were separated by foam spacers.

Cara Santa Maria: They hid the sensor plates inside a black rubber sleeve, and there you go. It looked just like any other industrial doormat. So they showed the mat to the police officers working the event and this is what they said.

Nilay Kulkarni: What if the mat itself is too thick and people trip over it?

Cara Santa Maria: A nightmare scenario.

Nilay Kulkarni: That would cause a stampede.

Cara Santa Maria: All he could picture was the same device he was hoping would save lives, endangering them.

Nilay Kulkarni: So it was a very big concern. We were scared.

Cara Santa Maria: They were working with a prefabricated sensor plate, so the height couldn't be changed.

Nilay Kulkarni: We tried and tested with different thicknesses of rubber sheets and it had to be lesser than 13 millimeters, I think. We were able to achieve nine or 10 millimeters.

Cara Santa Maria: And good thing because it's now just a few months until the start of Kumbh Mela.

Cara Santa Maria: Nilay and his team are pretty excited about their invention, but the rubber mat is just the data collection tool. Counting footsteps is great, but they still have to figure out what to do with that information. And this challenge falls to Nilay because he's the programmer on the team, which is fine but remember, he's just a teenager, now 15 years old and attempting to save hundreds of lives.

Nilay Kulkarni: Once the Arduino captures the data, it has to be transmitted to our servers. We built this REST API that would just ... It was basic STTP calls that would receive the count and it would record Unix time and the count of people with the mat identification number which would tell us where the mat was located.

Cara Santa Maria: Number, time, and location, the three pieces of raw data Nilay needs to solve his problem. So he sits down to write the software that will crunch the numbers.

Nilay Kulkarni: I knew some basics of C, C++, and Java, but this was real world deployment. It's quite different from the stuff that they teach you in school.

Cara Santa Maria: He went with Python and taught himself enough of the language to get it done.

Nilay Kulkarni: The mat identification numbers were set according to their location, so if the route was route A, a zero would be the entry point and a one, a two, and so on and so forth.

Cara Santa Maria: The mats gave a running total of people crossing at a certain threshold. Nilay then created an algorithm to extrapolate a dynamic picture.

Nilay Kulkarni: Every few minutes we would run a check. Say, if A1 and A2 report 7000 and 5000 respectively, we knew that 2000 people were in the zone between A1 and A2. We would divide the area by the 2000 people so that we would know what is the density in the particular area, the crowd density.

Cara Santa Maria: That's his algorithm. It forecasts when an area's becoming dangerous, and that's what he needs to give to the police.

Nilay Kulkarni: So we worked with the police for about a week to figure out what was an easy to understand and sort of a very precise dashboard. If a certain zone had passed a certain threshold, it would be marked red and would start flashing.

Cara Santa Maria: After two years, Nilay and his friends finally had a system. They could collect and analyze crowd data in real time and alert authorities to the potential for a progressive crowd collapse. But then something completely out of their control happened and it happened with only a few weeks left.

Cara Santa Maria: So this is what happened. In order for Nilay's algorithm to work, the data collected from every mat first goes to an Arduino board. Then the data has to get transmitted to a server where it can process the algorithm.

Nilay Kulkarni: We were using IoT SIM cards at that point to transmit the data.

Cara Santa Maria: IoT, that's Internet of Things, a SIM card built specifically for machine-to-machine communication.

Nilay Kulkarni: And we were told that IoT or machine-to-machine SIM cards were going to be disabled for the period of Kumbh Mela.

Cara Santa Maria: 30 million people are coming to the city. The telecom companies in Nashik can't support that many devices.

Nilay Kulkarni: Because the priority was humans and there weren't even enough towers to support humans. So M2M SIM cards had no chance.

Cara Santa Maria: Nilay had his data collection mats spread throughout the city. He was relying on the cell network to connect them to his server.

Nilay Kulkarni: The point was, who was accessing the Internet if it was directly on an Arduino board. It was detected that the operating system or the firmware is Arduino. So that it was marked as a machine accessing the Internet, not a human operating it.

Cara Santa Maria: He needed a way to fool the network.

Nilay Kulkarni: What we did was instead of installing a GPRS or an Internet SIM card module on our Arduino boards, we installed a Bluetooth module on it. We built an Android app that would connect to this Bluetooth device. It would extract the data every few minutes and this Android app would then send the data to the server. So we bought a few cheap Android phones and set them on auto such that they automatically take the data every five minutes. Now the transmission would always work because it was a human device. Android phones are counted as human operators.

Cara Santa Maria: Okay, so that's a sensor in a rubber mat counting footsteps connecting via Bluetooth to a cell phone buried in the ground beside it that sends a signal over the cellular network in an effort to trick the telecom company into thinking it's a human. Totally simple stuff, right? No, but really, all of this is so the foot count data can go to a server that runs Nilay's algorithm.

Cara Santa Maria: The data and algorithm are also displayed on a dashboard at police headquarters. If the algorithm decides an area is getting too crowded, it sounds an alert and headquarters will radio police officers to cut off access to the overcrowded area, hopefully avoiding the problems that can lead to a stampede.

Cara Santa Maria: It's the first day of Kumbh Mela and there's no one more nervous than 15-year-old Nilay. This is the day his grandfather warned him about.

Nilay Kulkarni: The atmosphere was electrifying.

Cara Santa Maria: Nilay's standing next to one of his mats when people start arriving.

Nilay Kulkarni: We saw the first hundred steps and then we said, okay, this is good. Then we saw the first 2000 steps. That was exciting.

Cara Santa Maria: Pretty soon they're in uncharted territory.

Nilay Kulkarni: After the 5000 footsteps, that was the maximum. We had never crossed even 5000 in any of our tests. 5000, and 10,000 and 20,000 was ... They were huge numbers. It felt really amazing we created a system that was able to endure through all of this.

Cara Santa Maria: For Nilay, this was a dream come true. But to the rest of the world, he just looked like a weird teenager that was way too interested in a couple of black rubber mats.

Nilay Kulkarni: I was scolded by one of the police officers for just sticking around for a long time. I seemed a suspicious guy.

Cara Santa Maria: The festival lasts for six weeks, but Nilay's focus was on the two biggest days, the holiest days of the event and the ones that attract the largest crowds.

Nilay Kulkarni: On the first day, it was I think 78,000 people in 18 hours. And then on the second day or the second Royal Bath day we counted 500,000 people.

Cara Santa Maria: When the festival ended and the millions of visitors had returned home, there was only one number that Nilay cared about.

Nilay Kulkarni: Zero.

Cara Santa Maria: That's right. Zero.

Nilay Kulkarni: In 2015, Nashik Kumbh Mela for the first time, zero deaths occurred, zero deaths due to stampedes.

Cara Santa Maria: In 2003, at the last Kumbh Mela in Nashik, 39 people were trampled to death and many more were injured.

Nilay Kulkarni: I thought my grandfather would have been very proud of me. In the car, after an exhausting day looking out of the car window, I was thinking about the conversation again and trying to imagine what my granddad would have said. It also felt like there was a movie being shot about this, starting from the point that the first conversation with my granddad and this was a beautiful end of it and a happy ending I guess.

Cara Santa Maria: Yeah. A happy ending for Nilay and the city of Nashik. But there are a few other cities in India that host their own Kumbh Melas.

Nilay Kulkarni: The idea popped that if we are not using the code, why don't I open source it and make it available for anyone to build a stampede prevention system in their own city.

Cara Santa Maria: It was picked up by a bunch of students preparing for the next Kumbh Mela in the city of Allahabad. So for now, Nilay has a new challenge.

Nilay Kulkarni: Oh yeah. Universities. I am applying to five universities and I really hope I get into maybe MIT or Stanford. The essays, they're quite difficult, but yeah, all of that stuff is also happening.

Cara Santa Maria: I think you got this, Nilay.

Cara Santa Maria: Okay, so you've been listening to Fixed That For You, a podcast by Segment about unusual problems solved with data and algorithms. If you want to find out more about Nilay's story, check out the show notes. You can find us at segment.com/podcast and subscribe at Apple Podcast, Google Podcast, Spotify, or wherever you do that sort of thing. We drop a new episode every two weeks.

Cara Santa Maria: I'm Cara Santa Maria. Thanks for listening.

Episode 01 - Data vs. Deadly Stampedes

Episode 01 - Data vs. Deadly Stampedes