MathGroup Archive 2009

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

Search the Archive

Compile Function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101305] Compile Function
  • From: "Christian Winzer" <christian.winzer at gmx.de>
  • Date: Wed, 1 Jul 2009 06:31:41 -0400 (EDT)

Hello,

I am trying to compile a function to speed up execution times.
>From what I have read in the previous posts, the function should return a
numerical value in order to be compileable. I think this condition is met.
Still the compile function does not seem to work: 


(*This example calculates the distribution of X = w * M + Z *)

(* Distribution of the stochastic variable M*) 

g = PDF[NormalDistribution[0, 1]]; 

G = CDF[NormalDistribution[0, 1]];


(* Distribution of the stochastic variable Z*) 

h = PDF[NormalDistribution[0, 1]]; 

H = CDF[NormalDistribution[0, 1]];


(* Weight of M in X*)
w = 0.5;

(*Conditional distribution of the stochastic variable X at point x=#1
conditional on M=#2 *) 

Qm = Evaluate[H[(#1 - w * #2)/(Sqrt[1 - w^2])]] &


(*Unconditional distribution of the stochastic variable X at point x*) 

Q = Integrate[Qm[#1, m]* g[m], {m, -\[Infinity], \[Infinity]}]& 

compiledQ = Compile[{x}, Integrate[Qm[x, m]* g[m], {m, -\[Infinity],
\[Infinity]}]]

compiledQ[1]
CompiledFunction::cfse: Compiled expression 1/2 (1+Erf[0.816497 (1.-0.5 m)])
should be a machine-size real number. >>
CompiledFunction::cfex: Could not complete external evaluation at
instruction 2; proceeding with uncompiled evaluation. >>

Comments and tipps are highly welcome :)!


Thank you very much for the advice and best wishes, 

Christian




  • Prev by Date: LogLinearPlot strange "features"
  • Next by Date: Re: Bug Report: Excessively thin Thin?
  • Previous by thread: Re: LogLinearPlot strange "features"
  • Next by thread: Re: Bug Report: Excessively thin Thin?