You are here

Gamma function

I would like to include a gamma probability distribution function in my model. I don't see a gamma function option in the inbuilt functions however. What would be the best way to bring this in?

Thanks

Forums: 

Hi,

The best way would be to provide an external function definition in C++, see help/equations/user.htm .

 

 

Thanks for the reply,

My problem is that I don't have a lot of experience integrating C++ like this. I have found a couple of gamma function C++ source codes, i.e. here, however I'm not sure how much of the code is relevent for this case - i.e. would I need the to include the math.h? I tried saving this code as a .cpp file in 'My Simile' folder, and adding a new prolog file (user_functions.pl) also in this folder to declare the function:

function(gamma, double, [double]).

this throws up the below error on opening of Simile (5.5)

Error parsing user-defined macros and functions in User_functions

Attempting to decipher this item failed, generating this diagnostic message: "} or operator expected". This is what was read in, with an indication of where the problem was found:

 Unknown <HERE> Unknown

Obviously I do need to review the various implementations of this function once I understand the integration into Simile better, and there might just be syntax errors in the code anyway. I'm just using the link provided as a test case. Would you be able to provide me with any clues?

Thanks in advance!