There is a set of points on the plane, (for simplicity, suppose that these are points with x coordinates from 0 to n)
For example, a = [0, 1, 4, 9] , where a[x] = f(x) .
It is necessary to write an algorithm that would classify the function of a chart constructed from these points.
I have already written the linear function classifier:
def is_linear(a): difference = a[1] - a[0] for i in range(len(a) - 1): if a[i + 1] - a[i] != difference: return False return True Now we need a classifier of a power function (well, or at least a quadratic form, y = ax ^ 2 + bx + c)
numpy.polyfit()). Examples - jfspolyfit(log(x[x>0]), log(a[x>0]), def=1)- jfs