forked from MartSlaaf/WNN-WN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wavelets.py
32 lines (26 loc) · 894 Bytes
/
wavelets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
__author__ = 'martslaaf'
from numpy import exp, cos, sin
class Morlet():
""" Morlet wavelet motherfunction.
"""
@staticmethod
def function(x):
return 0.75112554446494 * cos(x * 5.336446256636997) * exp((-x ** 2) / 2)
@staticmethod
def derivative(x):
return -4.008341100024355 * exp((-x ** 2) / 2) * sin(5.336446256636997 * x) - 0.75112554446494 * x * exp((-x ** 2) / 2) * cos(5.336446256636997 * x)
@staticmethod
def from_freq(freq):
return 0.8458 / freq + 0.0005407
class Mhat():
""" Mexican hat wavelet motherfunction.
"""
@staticmethod
def function(x):
return (1 - x ** 2) * exp((-x ** 2) / 2)
@staticmethod
def derivative(x):
return -x * (1 - x ** 2) * exp((-x ** 2) / 2) - 2 * x * exp((-x ** 2) / 2)
@staticmethod
def from_freq(freq):
return abs(0.2282 / freq - 0.001325)