# Tag Info

0

Define a function to calculate distance between two latitudes and longitudes. I found php implementation of below here. I converted it to python. import numpy as np import math def getDistanceBetweenPoints(latitude1, longitude1, latitude2, longitude2): theta = longitude1 - longitude2 distance = math.sin(np.radians(latitude1)) * math.sin(...

0

I think your problem is not so much calculating the average, as it is to create a subset within a radius. Once you have that subset, calculating the average is trivial. You find an example of subsetting on radius here: https://stackoverflow.com/questions/59060532/calculate-coordinates-inside-radius-at-each-time-point Note however that that example works ...

0

The error stemmed apparently from the formula for the gradient: there should be no minus sign (-) at the start of it. The correct code for this would be: function [jValue, gradient] = costFunction(theta, m, X, Y) V = X*theta; jValue = (-1/m)*sum(Y.*log(sigmoid(V)) + (1-Y).*log(1-sigmoid(V))); gradient = (1/m)*X'*(sigmoid(V)-Y); end

Top 50 recent answers are included