Re: Don't understand replacement rule for some functions
- To: mathgroup at smc.vnet.net
- Subject: [mg89559] Re: Don't understand replacement rule for some functions
- From: dh <dh at metrohm.ch>
- Date: Thu, 12 Jun 2008 06:31:05 -0400 (EDT)
- References: <g2qhhr$8or$1@smc.vnet.net>
Hi Mac, arguments of functions without special attributes like HoldFirst,.. are evaluated before beeing fed to the function. Therefore, RandomReal[GammaDistribution[L, 1/L], 2] is evaluated before beeing fed to ReplaceAll. You may prevent this by wrapping it into Hold or HoldForm. Hope this helps, Daniel Mac wrote: > Can somebody explain why the following replacement rule works > > In[15]:= f[x] /. x -> y > > Out[15]= f[y] > > and this one complains > > In[14]:= RandomReal[GammaDistribution[L, 1/L], 2] /. L -> 3 > > During evaluation of In[14]:= RandomReal::parpos: The parameter L in \ > position 1 of GammaDistribution[L,1/L] should be positive >> > > Out[14]= {1.89311, 1.11748} > > I find it quite elegant to use replacements for complicated functions > but I'm never quite sure whether the replacement is actually carried > out because of such behavior. > > Many thanks again for your help. > > Mac > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>