Wednesday, October 12, 2016

October 12, 2016 at 03:06AM

Today I Learned: 1) Here's a little algorithmic puzzle: You have a point (x,y) somewhere in the unit square, where one corner of the square lies at (0,0), the other at (1,1). You want to "jiggle" the point by moving it around randomly, in any direction, in a kind of Gaussian way. What algorithm do you use to make sure the point doesn't leave the square? Can you make it efficient? It's a trickier puzzle than it looks. It's not capital-D Difficult, but it's tricky. Try it. Ok, so here's an algorithm I used: 1) Pick a random angle theta, uniformly sampled between 0 and 2*pi radians. Then draw a number N from a Gaussian centered at zero. Try adding N*sin(theta) to the point's y-coordinate and N*cos(theta) to the point's x-coordinate. If that point leaves the unit square, draw another N and try again. Today I learned that this isn't a good algorithm. It works most of the time, but if you have a point in the corner and you get an angle facing the wrong way, it goes infinite (or close to infinite) and breaks. For example, imagine the point is at (1,0) and you pick 45 degrees as your angle. Now, no matter what N you choose, it'll be outside the unit box. There's a simple fix -- re-choose the angle every time you re-choose N, and before too long you'll get a good combination. Can you come up with an algorithm that isn't as wasteful? 2) A timing belt (or cam belt) is a geared belt that physically synchronizes various valves in an engine. If it fails, the engine can do really nasty things involving terms like "catastrophic failure". Apparently it's also possible for a timing belt to be off in such a way that causes accelerator input to the engine to be delayed, though I don't see how that's actually possible. 3) Mantis eyes may change color over the course of the day? I noticed that my mantis's eyes were dark, almost opaque. This made me a little worried, because usually I can see right to the back of the eye, where there are little itty bitty pupil-like spots. Later, though, it went back to normal, so I guess it's not a problem? I'm going to have to keep an eye on this.

No comments:

Post a Comment