changeset 414:643dbccde1fc

Added noise functions
author Joseph Turian <turian@iro.umontreal.ca>
date Fri, 11 Jul 2008 15:29:37 -0400
parents f63dfb0ac7dc
children 319bf28c2dd5
files noise.py
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/noise.py	Fri Jul 11 15:29:37 2008 -0400
@@ -0,0 +1,13 @@
+def binomial(input, rstate, p = 0.75):
+    """
+    Op to corrupt an input with binomial noise.
+    Generate a noise vector of 1's and 0's (1 with probability p).
+    We multiply this by the input.
+
+    @note: See U{ssh://projects@lgcm.iro.umontreal.ca/repos/denoising_aa}
+    to see how rstate is used.
+    """
+    noise = rstate.gen_like(('binomial',{'p': p, 'n': 1}), input)
+    noise.name = 'noise'
+    return noise * input
+