I created this labary to contain spcific methods that help me solve novel, yet common, problems.
These are written light-weight to run on micropython
Import the special math object that contains the methods
from specialmath import SpecialMath
sm = SpecialMath()
Mean takes a list of numbers and returns the average
sm.mean([1,2,3])
returns 2.0
SSE takes 2 lists of equal length and returns the sum of square error
sm.SSE([1,2,3],[2,3,4])
returns 3
Returns a list that is a full rotation of a sine wave
- Argument 1: length of output list
- Argument 2: amplitude of sine wave
- Argument 3: phase shift of sine wave
sm.gen_sin(10,8,2.5)
returns [-20.0, -16.18033988749895, -6.180339887498947, 6.180339887498947, 16.18033988749895, 20.0, 16.18033988749895, 6.180339887498959, -6.18
0339887498954, -16.180339887498945]
Returns a tuple size 2 that contains (1) the amplitude and (2) the phase shift. Takes 2 arguments :
- Argument 1: Imput list containing the data to shape the sine wave to
- Argument 2: Accuract factor, detirmines the number of itterations taken to estimate the wave properties. The higher the number, the more accurate and the longer computational time
sm.fit_sin([-4,0,4,0],8)
returns (3.9999744, 0.99993896484375)
Add a method to calculate the Standard Deviation
Written By Kipling Crossing