Tuning Python to data points less sensitive to random noise

I have a set of measured radii (t + epsilon + error) with equally spaced angles. The model is a circle of radius (R) centered at (r, Alpha) with added little noise and some random error values ​​that are much more noise.

The task is to find the center of the circular model (r, Alpha) and the radius of the circle (R). But it should not be too sensitive to random error (at the bottom of the data at 7 and 14).

Some radii may be missing, so a simple average will not work here.

I tried least square optimization, but it responds significantly to error.

Is there a way to optimize the smallest deltas but not the smallest squares delta in Python?

Model:
n=36
R=100
r=10
Alpha=2*Pi/6

Data points:
[95.85, 92.66, 94.14, 90.56, 88.08, 87.63, 88.12, 152.92, 90.75, 90.73, 93.93, 92.66, 92.67, 97.24, 65.40, 97.67, 103.66, 104.43, 105.25, 106.17, 105.01, 108.52, 109.33, 108.17, 107.10, 106.93, 111.25, 109.99, 107.23, 107.18, 108.30, 101.81, 99.47, 97.97, 96.05, 95.29]

+3
2

, Python?

, (, , scipy.optimize.fmin), . , , . ( , -, .)

, , . " ", " ".

. , , (0,5) (1,9) y = a, a 5 9 (4). , .

, . RANSAC ROUT.

+1

, . , , , ( , .)

numpy, :

def remove_outliers(data_points, margin=1.5):
    nd = np.abs(data_points - np.median(data_points))
    s = nd/np.median(nd)
    return data_points[s<margin]

.

numpy, - python:

def median(points):
    return sorted(points)[len(points)/2] # evaluates to an int in python2

def remove_outliers(data_points, margin=1.5):
    m = median(data_points)
    centered_points = [abs(point - m) for point in data_points]
    centered_median = median(centered_points)
    ratios = [datum/centered_median for datum in centered_points]
    return [point for i, point in enumerate(data_points) if ratios[i]>margin]

, , .

- , - , , , .

, , , : ( , - , , .)

def low_pass(data, alpha):
    new_data = [data[0]]
    for i in range(1, len(data)):
        new_data.append(alpha * data[i] + (1 - alpha) * new_data[i-1])
    return new_data

.

+2

All Articles