Durakken - 7 months ago 43

Javascript Question

I'm looking to try to take the data from here in the population/homerange image. and make it so I can put in any number from 1 to whatever and get the homerange that falls on the 3 number sets given.

The problem is I don't know how scaling exponents work and these types of equations I've never been good at on the programming side, so anyone willing to quickly throw together the javascript equation for this?

The 3 number sets are...

10 pop | 5.6 sq km

50 pop | 18.8 sq km

100 pop | 31.6 sq km

supposedly there is a .75 scaling exponent, but I don't see the correlation.

I tried looking around to find an example of what to do, but I can't find a simple easy to understand answer and the wikipedia entry on the subject just looks like a garbled mess to me.

Answer

Let's put it in a simple form:

H = P^{s}

where H is the home range, P is the population and S is the scaling exponent.

In Javascript, you can use the `Math.pow()`

function:

```
var scalingExp = 0.75;
console.log(Math.pow(10, scalingExp).toFixed(1));
console.log(Math.pow(50, scalingExp).toFixed(1));
console.log(Math.pow(100, scalingExp).toFixed(1));
```