Apologies for being dense, but I'm missing something. All three forms
( f(x), def f(x) and f=lambda x: ) are giving the same results.
Trying:
---------
var('x')
T=RealDistribution('gaussian',1)
def f(x):
return sin(x)+ T.get_random_element()
plot(f(x),(x,0,2*pi))
---------
and
--------
var('x')
T=RealDistribution('gaussian',1)
f=lambda x: sin(x)+ T.get_random_element()
plot(f(x),(x,0,2*pi))
---------
all give me a clean sine with a random offset, rather than sine
+noise...
On Mar 30, 2:30 pm, William Stein <[email protected]> wrote:
> On Tue, Mar 30, 2010 at 2:21 PM, G B <[email protected]> wrote:
> > Hi--
>
> > I'm trying to figure out how to use RealDistributions to model noise.
> > For example, I would like to model a signal+noise and tried using this
> > construct:
>
> > T=RealDistribution('gaussian',1)
> > f(x)=sin(x)+T.get_random_element()
> > plot(f(x),(x,0,2*pi))
>
> > Unfortunately, that only calls get_random_element() once, at the
> > definition of f(x) and results in a perfect sinusoid offset by a
> > random value.
>
> def f(x):
> return sin(x) + T.get_random_element()
>
> or
>
> f = lambda x : sin(x) + T.get_random_element()
>
> William
>
>
>
> > How do I write this so that get_random_element() is called each time
> > f(x) is evaluated? I would like to see a noisy sinusoid.
>
> > Thanks--
> > Greg
>
> > --
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group
> > athttp://groups.google.com/group/sage-support
> > URL:http://www.sagemath.org
>
> > To unsubscribe from this group, send email to
> > sage-support+unsubscribegooglegroups.com or reply to this email with the
> > words "REMOVE ME" as the subject.
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washingtonhttp://wstein.org
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org