Created
November 5, 2017 16:21
-
-
Save RodrigoPrior/d8199eaf2fda244560d5376514dbd6ae to your computer and use it in GitHub Desktop.
Example of Haar Mother Wavelet in python using np.piecewise interval definition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Haar Mother Wavelet. | |
Example of Haar Mother Wavelet in python using np.piecewise interval definition. | |
""" | |
# Ref.: | |
# https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.piecewise.html | |
# https://sfalsharif.wordpress.com/2009/12/18/piecwise-function-definitions-in-numpy/ | |
import numpy as np | |
import matplotlib.pyplot as plt | |
t = 1 | |
x = np.arange(-2, 2, 0.1) | |
y = np.piecewise(x, | |
[(x>=0) & (x < t/2), (x>= t/2) & (x < t)], | |
[lambda x: 1, lambda x: -1, lambda x:0]) | |
plt.stem(x,y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment