There exists a mountainous land in a galaxy far, far away (called MKWorld) where a number (n) of strange magical animals roam. All these animals have a location device attached to them, which periodically outputs their coordinates (x,y) and height above sea LEVEL (note that some animals may live in the deep sea). You are a biologist studying these animals. However, unfortunately you can never see these animals ( “far, far away”). The only information you have for your scientific inquiry is the text files produced by the location devices. Each file contains a (potentially very long) record (or time series) of the roaming of a particular animal. This is a list of numbers with the format:
<counter> <x> <y> <height>
Here, <counter> keeps track of the number of readings recorded
– it will be sequential, but may count in increments greater than 1. The coordinate values <x> and <y> can be thought of as the latitude and the longitude, but may have odd ranges - this is not Earth!
Also, note that counter must be a long value and <x> , <y> and
<h> are floating point values.
The magical strength (M) of each animal is determined by the temperature (which is constant throughout the land), their current x,y position and height h, according to the following expression:
M[x][y] = -T*ln(P(x,y)) – h
Here, P is the probability of animals being at a particular point. Probability is calculated in a straightforward manner as the number of times that an animal is at a particular x,y value divided by the total number of records. To make things easier, you will divide the2D space into blocks and calculate a 2D histogram of the x,y frequency for each animal in each block and then calculate the probabilities of each block from that. The accuracy of this approach is determined by the block size, which is determined by the number of divisions, or bins, in each dimension. You decide that this will best be done with an input parameter, to allow you to fiddle with different grid resolutions. You also don’t know the range of values for either <x> or <y>, but will need to obtain them from scanning the file.
Finally, for the formula you will also need to calculate the average height for each grid point.
The application should output the magical strength matrix for each animal individually, as well as a magical strength matrix for all the animals together. It should be as concurrent as possible – you want research results quickly!