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 at 
> http://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 Washington
http://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

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.

Reply via email to