Clark's formula - population density [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a problem:
C. Clark's model of urban population densities indicating that population density varies with distance from the center of the city according to the equation Dx=D0e-bx where Dx is the population density at distance x from the center. D0 is the density at the center, e is the base of the natural logarithms, and b is a natural logarithm measuring the rate of change of density with distance.
How can I write this formula in php language?
Thanks!
What I have tried:
Dx = D/(x/b*b);
But I thinks this is wrong.

Not sure what's the problem here, so here's how I got it and you can say what did I get wrong. Afterwards, you can edit your question :)
Hence:
// this should be given
$d0 = 1.22;
$b = 0.37;
function dx($x = 0) {
global $d0, $b;
return $d0 /exp($b*$x);
}
echo dx(6.74); // d_{6.74}

Related

Selecting points within a bounding square [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Help to make a selection from the database (mysql) of the coordinates.There is a table with fields latitude/longitude.The sample should be in the form of a rectangle. Thank you! example
I tried it http://www.movable-type.co.uk/scripts/latlong-db.html, but it is necessary in the form of a predetermined size of the rectangle
If you need select the point inside a rectangle is
Assuming that your rect have thr coord ($minLat , $minLng , $maxLat, $maxLng)
You can simply select the points this way
select * from my_table
where
point_lat >= $minLat
AND point_lat <= $maxLat
AND point_lng <= $maxLng
AND point_lng >= $minLng;

How to find latitude and longitude lies within radius? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have latitude and longitude of place. How to find these latitude and longitude lies within some other locations radius?
for example having (6.8914,79.8522) (lat,long) of location,and find within location (6.9584218,80.1783008) of radius 10.
please help me.
lat1 = 6.8914 # latitude of point 1
long1 = 79.8522 # longitude of point 1
lat2 = 6.9584218 # latitude of point 2
long2 = 80.1783008 # longitude of point 2
if distance between two geographical points < 10:
point2 lies inside radius
else:
it doesn't
You may seek idea how to calculate distance between two geographical points and the programmatical implementation by using Haversine Formula here.

Display an icon for each number of bedrooms (property website) php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a property website.
At the moment, on the listing, and in search results, it says Number of bedrooms: [pulls the number from the database]. It uses an array variable, $a1[rooms].
Instead, I want to display a small icon of a bed for the number of bedrooms. So if three bedrooms then it should say, Number of bedrooms: [bed img] [bed img] [bed img]. [bed img] of course being a small icon/image of a bed.
So whether there are 1 bedrooms or 5 bedrooms, this is the number of times I want the icon displayed. The number of bedrooms is stored here: $a1[rooms].
Fairly simple really.
Thanks in advance.
Something like this will do the trick:
for ($bed_counter = 1; $bed_counter <= $a1['rooms']; $bed_counter++) {
print '<img src="bed.jpg">';
}

change specific values of array in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
<?php
$x=6;
$y=9;
$time = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
for ($i=$x;$i<=count($y);$i++)
{
If($x!=$y)
{
$time[$i]=1;
}
}
?>
Depending on the value of x and y,the values in array should change.
In this example... array[5] until array[8] should be value 1.
The value of x and y will not same.
Not a very good question, but I'm a little bored. So for fun:
array_splice($time, $x-1, $y-$x-1, array_fill(0, $y-$x+1, 1));
Not exactly sure of the logic using 6 and 9 and array[5] until array[8] is, but adjust the numbers to fit the range.

Calculating distance between two points on a flat plane? (php) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
3rd grade question:
How do you calculate the distance between two points on a flat surface?
I have been going through the Google_Results and it seems everything i find applies to Long/Lat and not a flat surface.
I'm working on making ObjectA choose between ObjetsC,D,E... , select the closest one and move toward it. So I have to loop through my SQL table, pull out what's in range, and loop through the results to calculate distances.
Any help with this math I haven't had to remember in years would be appreciated.
You will need to use a Euclidean distance formula (specifically for 2 dimensions). Basically the formula is:
d = sqrt((x1 - x2)^2 + (y1 - y2)^2)
d is your final distance
sqrt is the square root (the sqrt() function in PHP)
x1 and y1 are your x-y coordinates for your first point
x2 and y2 are your x-y coordinates for your second point
^2 means raise to the second power (use the pow() function for PHP)
Pythagoras was the Greek philosopher who developed the Pythagorean Theorem, which can be used to derive the 2-dimensional distance formula (which is different from Euclid's derivation).

Categories