0

I am a new mathematica user. I am trying to use the Compile command to speed up my RandomFunction output. The code looks like this:

test2 = Compile[{{ab, _Real}}, 
   Module[{counts, values}, counts = ab + 1;
    proc = 
     ItoProcess[{\[DifferentialD]x[
          t] == -x[t]  \[DifferentialD]t + \[DifferentialD]w[t]}, 
      x[t], {x, 0.0}, t, w \[Distributed] WienerProcess[]];
    result = RandomFunction[proc, {0, ab, 0.01}];
    values = result["Values"];
    values]];

abc = test2[1];

However, this gives me the following errors: CompiledFunction::cfse: Compiled expression {0.,-0.0293342,-0.113584,-0.18336,-0.183176,-0.1791,-0.291471,-0.256793,-0.177335,-0.0997472,<<91>>} should be a machine-size real number. CompiledFunction::cfex: Could not complete external evaluation at instruction 5; proceeding with uncompiled evaluation.

I don't understand the issues. Is the function RandomFunction even compatible with Compile? Please help.

  • Preliminary question: your ItoProcess is independent of the input, so why not defining it once and for all at the start ? – b.gates.you.know.what Mar 13 '24 at 21:24
  • Thanks for the comment. Mostly because I am new and was trying different things out. It didn't change the output if I defined ItoProcess outside the Compile block. – rahman62 Mar 13 '24 at 21:28
  • 1
    Welcome to Mathematica StackExchange! Unfortunately, neither ItoProcess nor RandomFunction are among compilable function, which means you will not gain any performance optimization by compiling the function, because the compiled function will have to call back the main kernel to evaluate this. I am not sure why there is an error message, though, but this doesn't change the main problem :) – Domen Mar 14 '24 at 09:29
  • Thanks a lot, Domen. Makes total sense now. – rahman62 Mar 14 '24 at 15:00

0 Answers0