Hypergeometric function

Use this forum to post Vensim related questions.
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Hypergeometric function

Post by lorenzo.cioni »

Hi
is there any way of implementing an hypergeometric function 1F1 with 3 parameters a, b and c in Vensim PLE Plus obviously through some other functions?
Al the best and many thanks for any suggestion.
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

Can you give an example of what you want to implement?

And if you upload what you've tried, that would help as well.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:Can you give an example of what you want to implement?

And if you upload what you've tried, that would help as well.
Hi
thank you a lot. I'm trying to use Vensim to model a probability of infection with a relation I found in Teunis et alii 2016 "A generalized dose-response relationship for adenovirus infection and illness by exposuere pathway" where you can read that (relation (2))
Pinf(dose|a,b)=1-1F1(a,a+b, -dose)
At the present I've no model to upload, sorry.
All the best.
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

Have you tried to replicate the 1F1 function in Vensim? The source code (in C (GNU Scientific Library)) is available on the internet.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:Have you tried to replicate the 1F1 function in Vensim? The source code (in C (GNU Scientific Library)) is available on the internet.
Hi
I just looked for some definitions and I found out some here
http://functions.wolfram.com/Hypergeome ... ric1F1/02/
but none, imho, directly replicable in Vensim.... any suggestion? I'm using Vensim PLE.
Lorenzo
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

I found this site
http://keisan.casio.com/exec/system/1349143651
that looks nice. Unfortunately my z parameter is a dose parameter that increases over time depending on a certain number of other parameters and from the running time of my simulations too so I cannot use that tool...
any idea?
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

Unfortunately, it looks like the easiest option might be to build an external function to do this (using the GNU Scientific Library).
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:Unfortunately, it looks like the easiest option might be to build an external function to do this (using the GNU Scientific Library).
Thank you... unfortunately for me I'm a newbie of programming and have no idea of GNU Scientific Library so it would be very nice of you if you could give me some details, examples and references on how to proceed in Vensim PLE.
All the best.
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

External functions cannot be implemented in PLE.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:External functions cannot be implemented in PLE.
Gosh... any shortcut for solving my problem?
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

I've already suggested trying to replicate the function using the GSL source files, this is all you can do in PLE.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:I've already suggested trying to replicate the function using the GSL source files, this is all you can do in PLE.
I remember but you too should remember that I asked you some more details on how to proceed and I'm still waiting... 8)
Lorenzo
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

lorenzo.cioni wrote:
Administrator wrote:how to proceed and I'm still waiting
Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Hypergeometric function

Post by tomfid »

The difference between the hypergeometric distribution and the binomial distribution is drawing without vs. with replacement.

So, as long as the populations N and K are large with respect to the number drawn n, or n = 0 or 1, you can get a close approximation with RANDOM BINOMIAL.

This will generally be true as long as TIME STEP is small with respect to the time scale of the infection process.
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

tomfid wrote:The difference between the hypergeometric distribution and the binomial distribution is drawing without vs. with replacement.

So, as long as the populations N and K are large with respect to the number drawn n, or n = 0 or 1, you can get a close approximation with RANDOM BINOMIAL.

This will generally be true as long as TIME STEP is small with respect to the time scale of the infection process.
Hi tomfid
maybe there is a misunderstanding... I'm talking about an hypergeometric function and not distribution: are you sure they are the same thing? :roll:
Anyway thank you a lot.
Lorenzo
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:
lorenzo.cioni wrote:
Administrator wrote:how to proceed and I'm still waiting
Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.
I have searched and I've found that the funciotn is implemented through a routine called gsl_sf_hyperg_1F1 but I was able to find only references in pdf files but no source code, could you please be more precise?
Thank you a lot.
Lorenzo
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

lorenzo.cioni wrote:
Administrator wrote:
lorenzo.cioni wrote:
Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.
I have searched and I've found that the funciotn is implemented through a routine called gsl_sf_hyperg_1F1 but I was able to find only references in pdf files but no source code, could you please be more precise?
Thank you a lot.
Lorenzo
A curiosity: any relation with gamma functions/distributions?
L.
Administrator
Super Administrator
Posts: 4573
Joined: Wed Mar 05, 2003 3:10 am

Re: Hypergeometric function

Post by Administrator »

lorenzo.cioni wrote:could you please be more precise?
No (I had never heard of the function before you posted today).

I found the GNU Scientific Library when searching for 1F1. All I can suggest is downloading the source code and searching it.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Administrator wrote:
lorenzo.cioni wrote:could you please be more precise?
No (I had never heard of the function before you posted today).

I found the GNU Scientific Library when searching for 1F1. All I can suggest is downloading the source code and searching it.
Ok, thank you a lot.. at the ned I found the code but I'm 99% sure it cannot be used within Vensim without defining an external function and this definitely excludes the PLE version of the program.... :( :(
Lorenzo
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Hypergeometric function

Post by tomfid »

Ah ... I think the function is just a generalization of the series that appears in the pdf of the distribution. Seems like you should be able to implement the integral representation here,
http://mathworld.wolfram.com/ConfluentH ... tKind.html
because Vensim has the log Gamma function. (Maybe not in PLE though.)

What the heck are they using this for?
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

tomfid wrote:Ah ... I think the function is just a generalization of the series that appears in the pdf of the distribution. Seems like you should be able to implement the integral representation here,
http://mathworld.wolfram.com/ConfluentH ... tKind.html
because Vensim has the log Gamma function. (Maybe not in PLE though.)

What the heck are they using this for?
Hi tomfit
if I understand you well you are referring to relation (3). Are you sure it can be implemented in a Vensim model? :? :?
Lorenzo
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

lorenzo.cioni wrote:
tomfid wrote:Ah ... I think the function is just a generalization of the series that appears in the pdf of the distribution. Seems like you should be able to implement the integral representation here,
http://mathworld.wolfram.com/ConfluentH ... tKind.html
because Vensim has the log Gamma function. (Maybe not in PLE though.)

What the heck are they using this for?
Hi tomfit
if I understand you well you are referring to relation (3). Are you sure it can be implemented in a Vensim model? :? :?
Lorenzo
Tomfid, sorry
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Hypergeometric function

Post by tomfid »

Tomfid, sorry
No problem.

I'm not 100% certain, but the integral breaks up to terms with e^x, xe^x, and x^2e^x, so it should be solvable. The gamma function may be a problem in PLE though.
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

tomfid wrote:
Tomfid, sorry
No problem.

I'm not 100% certain, but the integral breaks up to terms with e^x, xe^x, and x^2e^x, so it should be solvable. The gamma function may be a problem in PLE though.
Hi Tomfid
I was able to find this nice calculator
http://keisan.casio.com/exec/system/1349143651
so I will get a set of points of my dependent variable P having fixed the values of a and b and having only z vary over a certain set of values so to be able to implemet my function with a lookup in Vensim with z (the dose) as the only independent variable.
Thank you a lot (and to Adminisrtator too, of course) for having devoted part of your time and efforts to help me.
Lorenzo
PS I'll let you know....
lorenzo.cioni
Senior Member
Posts: 102
Joined: Wed Jul 30, 2014 7:09 am
Vensim version: PLE

Re: Hypergeometric function

Post by lorenzo.cioni »

Hi
could you please check the attached model and explain the seemingly absurd behavior of the 1F1 variable through which I'm trying to implement the infinite series expression of such the 1F1 Hypergeometric function?
How many terms should I consider? Is there any better and more clever way (in Vensim, of course)?
All the best.
Lorenzo
Attachments
ModelloDoseResponseQMRA14112017TempoIndipendenteParametriCostantiNoDistribuzioni.mdl
(15.54 KiB) Downloaded 134 times
Post Reply