Re: Compiling Random Numbers from a distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg84489] Re: Compiling Random Numbers from a distribution
- From: "Michael Weyrauch" <michael.weyrauch at gmx.de>
- Date: Sat, 29 Dec 2007 02:57:59 -0500 (EST)
- References: <fl2eme$eqh$1@smc.vnet.net>
Hello, if you set the appropriate system option using Developer`SetSystemOptions["CompileOptions" -> {"CompileReportExternal" -> True}] and then compile your functions v or v1 you will find from the messages which are then printed out, that neither NormalDistribution nor RandomReal can be compiled, and will be evaluated externally. So compiling isn't really useful for your functions. Also note, that any expression involving global variables cannot be compiled. Compilation only succeeds if the Compiler can determine the type of the variables as described in the help pages of Compile, which is not possible in case of v1, since RandomReal does not have a "known" type in this sense. (I admit that it is somewhat surprising that RandomReal cannot be compiled, but that's how it seems to be.) Often is is also useful to inspect the "compiled code", which can be displayed using InputForm. While the code isn't really readable, it is useful to make sure that no {..Function..} appears in the code. This is another indication that compilation did not fully succeed. Michael Weyrauch