04
Feb 13

Landmine detection revisited; the inverse unicorn problem

A couple weeks ago I wrote about an interesting idea to clear landmines using the power of the wind. A reader asked me to comment more on the value of using these wind-powered “Kafons” to do an initial assay of a suspected minefield, an idea I mentioned at the end of my video on the subject. In particular, how good would the devices be at detecting the existence of mines if they were very sparse in an area? In a sense, this is the inverse of the unicorn problem; instead of trying to find every last mine, we’re concerned with finding the very first one, if indeed land mines are there. Put another way: How hard do we have to look before we can safely conclude that unicorns don’t exist?

Download the code for this simulation.

The animated plot shown at the top of this post represents a small sample of data from the simulation I ran. Each blue dot shows the progress of testing of a location to see if that field has mines. I’ve cutoff the testing at $30,000, which is 600 kafons based on their estimated cost (feel free to go into the code and change the cutoff to whatever you want). The dots at the top, with numbers above them, represent testing that used all 600 kanfons without finding any mines. Does this mean no mines exist? Sometimes, but not always. The number above the dot shows the true number of mines in that field during that particular simulation. As you can see, it’s very possible for the field to have several mines, yet still not have any detected, even after trying with hundreds of kafons. In the entire simulation, there were 283 trials with a single mine in the field. On 36 of those occasions, the mine was detected (and, in the simulation, detonated). The other 87% of time, we spent a (virtual) $30,000 and failed to detect its presence.

I’ve shown the results as an animation so that you can put yourself into the position of someone trying to decide whether to continue testing a field for mines, or move on to another location. Each new test costs additional funds, but when do you stop? My $30,000 cutoff is arbitrary. It represents a best guess on my part as to when it would be better to use other methods to test for landmines. These kinds of optimal stopping points can be extremely difficult to determine, especially when, as in this case, those testing for landmines will have to deal with the problem of sunk costs: imagine you’ve just spent $30,000 testing for mines in a field you suspect is dangerous, but you haven’t found anything. The very next kafon, at a cost of just $50, could be the one to find a mine. Do you continue? In my simulation, with this particular distribution of probabilities, once no mine was found in the first 300 kafons, it was very unlikely one would ever be found (although, as mentioned, even when no mine was detected after 600 kafons the field was still way more likely than not to have mines).

Based on the results of the simulation, using kafons to detect mines is cheap when the probability of finding a mine is very high, but in that case I would imagine there’s already strong evidence that landmines exist. In the case where landmines are more sparse, testing with kafons is expensive and the question of when to stop testing is difficult. Note that in a real world use, we don’t know the underlying probability of a mine in the field; we you could be anywhere along the x-axis of the plot shown at top. All we see, in real time, is a rising cost and no kafon found.

If we know how much (new) area is covered by each addition kafon, and if we assume that coverage and placement of landmines is randomly distributed (at least from our position of ignorance), then we can come up with some probability estimates for the chances that a field has an undetected landmine after each additional kafon is given a chance to detect mines. The biggest challenge is that, unless I’m missing something, the question of this exact probability is unanswerable unless we assume a prior distribution on the number of landmines in our field.

We wanted to let the data speak for itself in terms of whether we have hidden mines or not, but in the end, our final beliefs will depend as much on our previous hunch as on the data itself. Which is, in effect, exactly what we were hoping to avoid by sending out kafons to detect for mines.

Shown below is a full plot of all 2800 trials, each dot at the top might represent dozens of failed attempts to find a mine.


23
Jan 13

Fake text generation the wrong way, and a contest

As part of a bigger project, I needed to simulate a text string based on a source document, but at the character level. Just in case people find the code useful, I’ve uploaded it to MCMCtext.r.

In my simulated text, each character is chosen based on the transition probabilities in the source text from one character to another. The result is (nearly complete) gibberish without much interest to anyone, except perhaps those looking for a replacement for the standard Lorum Ibsum dummy text. More interesting fake text could be generated by using two character (or more) transition probabilities, or by working at the level of words.

Before moving on, I thought it might be interesting to see if anyone can “reverse engineer” my fake text output to figure out which original text was used as a source to generate it. Got that? The source text comes from Project Gutenberg. Hint: some features of the (fake) text could help you narrow the field of candidates.

First person to post a correct guess in the comments gets a copy of my comic and an unlimited supply of Hotpockets*. Limit one guess per person please.

* Hotpockets offer only valid if you are currently saving the planet from destruction.


21
Jan 13

Zero-information predictions for 2013

The embarrassing failure of experts to predict the future is well known and has been exhaustively cataloged by writers such as Nassim Taleb and Nate Silver. It often seems like the more someone knows about a subject, the worse they are at predicting what will happen in that area. In this spirit, I bring you seven predictions for the coming year, based on an absolute minimal amount of knowledge. Combined, I’ve spent less than one hour studying these topics, with the exception of bubbles in general. Here they are, we’ll see how well this exercise in ignorance holds up.

Prediction: The EU crisis will not be solved, more good money will be thrown after bad.
Source of prediction: The last three years. Also, bankers (for now) still rule the world.

Prediction: Bubbles will begin to burst. It could be the Higher Education Bubble, the Regulatory Complexity Bubble, the Government Money Printing (aka Fiat Currency) Bubble, or the closely related Global Debt Bubble.
Source of prediction: In Western, developed nations, all of these these have gone exponential. That never lasts because it can’t.

Prediction: Obamacare (officially know as PPACA, had to look that up), will begin to look like the Democrat’s Vietnam. Those who supported the legislation will need to make a quick u-turn or double down on their support, riding the increasingly unpopular, cost-overrunning quagmire into the depths of bureaucratic hell.
Source of prediction: I’m not a zombie.

Prediction: Speaking of soon-to-fail-in-its-intended-goals legislation, Dodd-Frank will have many nasty unintended consequences.
Source of prediction: It’s 8,800 pages long and still leaves lots of things to be worked out later by regulators.

Prediction: The meltdown at Fukushima will still be a problem at the end of the year.
Source of prediction: The most radioactive fish of all time (by a factor of 10) was just caught. The lovely, and glowing, Murasoi is shown at top.

Prediction: The Miami Heat will win the NBA. Oklahoma will peter out.
Source of prediction: I stopped watching the NBA a few years ago, but as I recall Miami is a good team, and no one plays pro basketball in Oklahoma.

Prediction: At this year’s Oscars, lots of pretentious, overwrought crap will get awards.
Source of prediction: Recent history, reading the nominee list, watching a trailer for Les Miz.


10
Jan 13

Simulation of landmine clearing with Massoud Hassani’s Mine Kafon

Code used: MineClearingSimulationWithKafons.r

TRANSCRIPT OF VIDEO:
Hello, I’m Matt Asher with StatisticsBlog.com. This video is about my attempt to simulate a landmine clearing device built by Massoud Hassani called the Mine Kafon. I’ve put a link to his webpage at StatisticsBlog.com, I highly recommend checking out the video. Hassani’s device looks like this:

It’s a cheap, easy to build mine clearer that travels under the power of the wind. When I first saw the video, I was awestruck by what Hassani had done. It seemed like an awesome achievement, cleaver, creative, a fantastic idea for making the world better. A device that used the power of nature to clean up after man.

The more I thought about it, though, the more I wondered what might happen if hundreds of Kafons were sent out onto a mine field. So to examine that question, I built a simulation. I’ll run it now.

I’ve slowed it down so you can see what’s happening. Each blue line represents the path a Kafon might take across the minefield. The red circles represent exploded mines, and the gray parts are places where paths have overlapped.

Based on Hassani’s video, I’ve assumed there’s a prevailing wind that sweeps the devices right out into the field, and that the Kafons are released at equal intervals at the edge of the minefield. The movements up and down represent turbulence, uneven ground, or the natural tendency of the Kafons themselves to move with a wobble.

I’ve posted the code to this simulation on my website, as I do for all my blog posts. It’s written in R, a free and open source programming language. You can go into my code and easily change the wind speed and other parameters, then re-run the simulation. For example, I’ve set the number of mines that each Kafon can absorb before it stops working to 4, that’s on based on what Hassani estimates, but you can change that up or down.

Paths that stop at a red circle before they traverse the whole minefield are Kafons that have “plated out” after hitting 4 mines.

Just looking at the simulation in this way, it seems to be working very well. Most of the Kafons are finding land mines, and lot of land mines are getting cleared.

The biggest problem I see with Hassani’s approach has to do with efficiency, especially as you try to get more and more of the mines detected. The more Kafons you send into the field, the more overlapping you get, and the lower your efficiency becomes, and the harder it gets to detect remaining mines. I ran the simulation with different numbers of Kafons, always spaced at equal intervals, which gives them the best chance to clear as many mines as possible.

Here’s a graph showing the percentage of unexploded mines still left versus the number of Kafons that were released into the minefield. Each point on the graph represents a new simulation with that many Kafons. As you can see, at first adding more Kafons gives an almost linear decrease in the percentage of mines left, but the closer you get to clearing all the mines, the more elusive that goal becomes. Even after 2000 Kafons have been released, which if moving perfectly straight could have covered the area of our simulation four times over, there are still some mines left unexploded.

If you look on my blog you’ll see a post I did about something I call The Unicorn Problem, related to finding all of the new species in an environment. The problem there, as with this approach, is that the marginal rate of detection goes down as the number of attempts goes up. What’s happening, is that the more Kafons you use, the more they overlap territory.

Here you can see the amount of territory that’s be traversed more than once by a Kafon. The overall result is that the cost per mine destroyed gets higher and higher as you get closer to and closer to eliminating all of them. Here’s a plot of the cost per destroyed mine versus the number of Kafons used.

End result is cost per mine detected keeps increasing. Hassini estimates a cost of 40 euros to build each device, or about $50.

I wish Hassani the best of luck with his project, hopefully these issues can be addressed. Whatever the faults with this approach, this is a very important thing he’s doing. I noticed that in a more recent video he mentioned tracking the Kafon’s motion with GPS. I don’t know whether his initial price estimate included the cost of GPS. At any rate this would help to keep track of which areas have been covered and which haven’t, but unless he’s using a GPS accurate to within a foot, I wouldn’t want to try and walk in the exact path cleared by the device. In my simulation I’m assuming that every single time the Kafon is in the area of a mine it explodes it. It’s not clear that would be the case. It would be easy enough to add a probability of failure to the simulation.

There are adjustments you can make to the simulation or its parameters which would result in more of the Kafons being effective, though any design that relies on wind patterns is going to suffer from the same diminishing returns and unicorn problem, even if the wind is widely turbulent and increases the probability that all of the plates will get used, there’s still the problem of overlap and perhaps even worse performance if the Kafons get stuck in one area, or are quickly blown out of the mine field. Overall there are lots of reasons not to want to walk out into a mine field, no matter how many kafons have been through it.

Even if the Mine Kafon isn’t the best option for clearing an entire region of mines, they might still be an effective way to test for the presence of mines in an area, to do a sample of the area and see how likely it is to contain land mines, and if so how many and what regions might have higher concentrations of mines.


14
Dec 12

Let it snow!

A couple days ago I noticed a fun piece of R code by Allan Roberts, which lets you create a digital snowflake by cutting out virtual triangles. Go give it a try. Roberts inspired me to create a whole night sky of snowflakes. I tried to make the snowfall look as organic as possible. There are lots of options to adjust. Here’s the code, have fun and Happy Holidays!

# Code by Matt Asher for statisticsblog.com
# Feel free to modify and redistribute 
 
# How many flakes do you want to fall?
flakes = 100
 
# Width and height of your space
width = 800
height = 600
 
# Initial wind
wind = 0
 
# Setup the background of the plot and margins
par(bg = "black")
par(oma=c(0,0,0,0))
par(mar=c(0,0,0,0))
plot(0, 0, col="black", pch=".", xlim=c(0,width), ylim=c(0,height), axes=F)
 
for(i in 1:flakes) {
    startY = height
    startX = runif(1,1,width)
 
    xPos = startX
    yPos = startY
 
    for(j in 1:height) {
 
		# Optional drift in wind
		wind = wind + rcauchy(1,0,.05)
 
		# Update snowflake position
        xPos = xPos + rnorm(1,.1,1.5)
        yPos = yPos - runif(1,4,20)
 
        # Are we in the space, if so display it
        if(xPos > 0 && xPos <= width && yPos > 0 && yPos <= height) {
            points(round(xPos), round(yPos), col="white", pch=8)
 
            # System dely, slows down the flakes
            Sys.sleep(0.1)
        }
    }
}