Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- graph1: 1 sin(x + 0 ) + 0
- graph2: 2 sin(x + 0 ) + 0
- graph3: 1 sin(x + 0 ) + 3
- graph4: 1 sin(x + 180 ) + 0
- def most_frequent(List):
- counter = 0
- num = List[0]
- for i in List:
- curr_frequency = List.count(i)
- if(curr_frequency> counter):
- counter = curr_frequency
- num = i
- return num
- def find_equation(graph):
- min_value = 10000
- max_value = 1
- values = []
- for coord in graph:
- #we dont need to find the min value, as it'll be the max value but with a changed sign
- if max_value < coord[1]:
- max_value = coord[1]
- if min_value > coord[1]:
- min_value = coord[1]
- values.append(coord[1])
- normal = int((min_value + max_value)/2)
- # print("Normal: ", normal)
- coef = max_value - normal
- # print("Max_value: ", max_value)
- # print("Coef:", coef)
- step = values[1] - values[0]
- # print("Step:", step)
- if step != 1:
- values = list(map(lambda x: int(x/step), values))
- if normal != 0:
- values = list(map(lambda x: x-normal, values))
- # print("Values:", values)
- real_values = [0, 1, 0, -1, 0]
- counter = 0
- if real_values != values:
- for value in values:
- counter += 1
- if value == 0:
- break
- # print("move by", counter)
- # print(values)
- print(coef, "sin(x + ", 90*counter, ") + ", normal)
- graph1 = [(0, 0), (90, 1), (180, 0), (270, -1), (360, 0)]
- graph2 = [(0, 0), (90, 2), (180, 0), (270, -2), (360, 0)]
- graph3 = [(0, 3), (90, 4), (180, 3), (270, 2), (360, 3)]
- graph4 = [(0, 1), (90, 0), (180, -1), (270, 0), (360, 1)]
- find_equation(graph1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement