Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Strange behavior: random and plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102726] Strange behavior: random and plot
  • From: Don Krug <krugd at nku.edu>
  • Date: Sat, 22 Aug 2009 03:36:55 -0400 (EDT)

Hi group.  I am new here and discovered some strange behavior (to me.) 
Hope someone can help.

I will be teaching a course on programming with Mathematica this 
semester and so you may hear from me some more.

I define

ran[x_]:=Random[Real,x]

If I evaluate ran[3]-ran[3] I get a non-zero result as expected.

But if I do

Plot[ ran[x]-ran[x] ,{x,0,3}]

  I get an empty axes system.  I assume it is the plot of the zero function.

I also know that if I set

ran2[x_]:=Random[Real,x]

then I get a non-zero plot as expected when I do

Plot[ ran2[x]-ran[x] ,{x,0,3}]

I am guessing the plot command is evaluating things in a strange way 
that forces the two instances of ran to be the same.

Can anyone explain why?

Thanks

Don Krug
Northern Kentucky U




  • Prev by Date: Re: Incongruence? hmm...
  • Next by Date: Re: Viewing packages in mathematica
  • Previous by thread: Re: Re: Viewing packages in mathematica
  • Next by thread: Re: Strange behavior: random and plot