[python-dtcwt] 33/497: added 1D example
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit e1a5d0d600882423d81c7c8cded36d729b8484a1
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Wed Aug 7 17:43:48 2013 +0100
added 1D example
---
docs/gettingstarted.rst | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst
index 866d70a..4da9330 100644
--- a/docs/gettingstarted.rst
+++ b/docs/gettingstarted.rst
@@ -35,6 +35,48 @@ Once installed, you are most likely to use one of four functions:
See :doc:`reference` for full details on how to call these functions. We shall
present some simple usage below.
+1D transform
+------------
+
+This example generates two 1D random walks and demonstrates reconstructing them
+using the forward and inverse 1D transforms. Note that
+:py:func:`dtcwt.dtwavexfm` and :py:func:`dtcwt.dtwaveifm` will transform
+columns of an input array independently::
+
+ import numpy as np
+ from matplotlib.pyplot import *
+
+ # Generate a 300x2 array of a random walk
+ vecs = np.cumsum(np.random.rand(300,2) - 0.5, 0)
+
+ # Show input
+ figure(1)
+ plot(vecs)
+ title('Input')
+
+ import dtcwt
+
+ # 1D transform
+ Yl, Yh = dtcwt.dtwavexfm(vecs)
+
+ # Inverse
+ vecs_recon = dtcwt.dtwaveifm(Yl, Yh)
+
+ # Show output
+ figure(2)
+ plot(vecs_recon)
+ title('Output')
+
+ # Show error
+ figure(3)
+ plot(vecs_recon - vecs)
+ title('Reconstruction error')
+
+ print('Maximum reconstruction error: {0}'.format(np.max(np.abs(vecs - vecs_recon))))
+
+ show()
+
+
2D transform
------------
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list