Hypergeometric function
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Hypergeometric function
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
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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
Can you give an example of what you want to implement?
And if you upload what you've tried, that would help as well.
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
HiAdministrator 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.
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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
HiAdministrator wrote:Have you tried to replicate the 1F1 function in Vensim? The source code (in C (GNU Scientific Library)) is available on the internet.
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
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
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
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
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
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.Administrator wrote:Unfortunately, it looks like the easiest option might be to build an external function to do this (using the GNU Scientific Library).
All the best.
Lorenzo
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
Gosh... any shortcut for solving my problem?Administrator wrote:External functions cannot be implemented in PLE.
Lorenzo
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
I remember but you too should remember that I asked you some more details on how to proceed and I'm still waiting...Administrator wrote:I've already suggested trying to replicate the function using the GSL source files, this is all you can do in PLE.
Lorenzo
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.lorenzo.cioni wrote:Administrator wrote:how to proceed and I'm still waiting
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Hypergeometric function
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.
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.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
Hi tomfidtomfid 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.
maybe there is a misunderstanding... I'm talking about an hypergeometric function and not distribution: are you sure they are the same thing?
Anyway thank you a lot.
Lorenzo
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
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?Administrator wrote:Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.lorenzo.cioni wrote:Administrator wrote:how to proceed and I'm still waiting
Thank you a lot.
Lorenzo
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
A curiosity: any relation with gamma functions/distributions?lorenzo.cioni wrote: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?Administrator wrote:Search Google fpr GSL 1F1, this will give you the source code. Try and replicate this in Vensim.lorenzo.cioni wrote:
Thank you a lot.
Lorenzo
L.
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Hypergeometric function
No (I had never heard of the function before you posted today).lorenzo.cioni wrote:could you please be more precise?
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
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
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....Administrator wrote:No (I had never heard of the function before you posted today).lorenzo.cioni wrote:could you please be more precise?
I found the GNU Scientific Library when searching for 1F1. All I can suggest is downloading the source code and searching it.
Lorenzo
Re: Hypergeometric function
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?
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?
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
Hi tomfittomfid 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?
if I understand you well you are referring to relation (3). Are you sure it can be implemented in a Vensim model?
Lorenzo
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
Tomfid, sorrylorenzo.cioni wrote:Hi tomfittomfid 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?
if I understand you well you are referring to relation (3). Are you sure it can be implemented in a Vensim model?
Lorenzo
Re: Hypergeometric function
No problem.Tomfid, sorry
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.
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
Hi Tomfidtomfid wrote:No problem.Tomfid, sorry
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.
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....
-
- Senior Member
- Posts: 102
- Joined: Wed Jul 30, 2014 7:09 am
- Vensim version: PLE
Re: Hypergeometric function
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
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 136 times