Calculating ratio when denominator is zero
Calculating ratio when denominator is zero
Hi,
In my model I want to be able to calculate a ratio x/y even when y = 0 (y cannot be negative in the model) . An easy way to do this in PLE Plus is simply to take the previous value of x/y but if y = 0 for two periods in a raw this solution does not work and I am forced to put a value for x/y that generates a discontinuty in the data.
I know that higher versions of Vensim have a function like "get data max" that would be helpful, but I do not have this option with PLE Plus.
Do you have any suggestion?
Thanks.
In my model I want to be able to calculate a ratio x/y even when y = 0 (y cannot be negative in the model) . An easy way to do this in PLE Plus is simply to take the previous value of x/y but if y = 0 for two periods in a raw this solution does not work and I am forced to put a value for x/y that generates a discontinuty in the data.
I know that higher versions of Vensim have a function like "get data max" that would be helpful, but I do not have this option with PLE Plus.
Do you have any suggestion?
Thanks.
division by zero
joined a model with two solutions, using the xidz function or the if then else
Regards.
J.J. Laublé
Regards.
J.J. Laublé
- Attachments
-
- division by zero.mdl
- (1.43 KiB) Downloaded 556 times
Ok but It is not what I would like to do
Ok but it is not what I would like to do. I know those functions.
What I would like to be able to do is to go back to the last value of the ratio that was not zero (or better the max value of the ratio) so that if for example the ratio is 5000 at a moment it does not drop suddenly to 0 or any other imposed value.
What I would like to be able to do is to go back to the last value of the ratio that was not zero (or better the max value of the ratio) so that if for example the ratio is 5000 at a moment it does not drop suddenly to 0 or any other imposed value.
division by zero
Hi
Joined the corrected model, that should work.
Regards.
J.J. Laublé
Joined the corrected model, that should work.
Regards.
J.J. Laublé
- Attachments
-
- division by zero.mdl
- (2.18 KiB) Downloaded 502 times
division by zero
Better use the stock solution, because I think that the sample if true function does not work in Ple Plus.
Reload the model joined as there was a mispelling of a variable.
Regards.
J.J. Laublé
Reload the model joined as there was a mispelling of a variable.
Regards.
J.J. Laublé
- Attachments
-
- division by zero.mdl
- (2.19 KiB) Downloaded 519 times
Allright guys,
I have tried both of your solutions and the "sample if true" function works best. What's weird, however, is that it works in PLE Plus (I checked the guide and, as one of you noticed, this function is normally not available in PLE Plus...but the model runs!).
The stock solution generates a floating point overflow error each time the max value goes above zero (or for any initial value superior or equal to zero).
Thanks for your suggestions and your time.
I have tried both of your solutions and the "sample if true" function works best. What's weird, however, is that it works in PLE Plus (I checked the guide and, as one of you noticed, this function is normally not available in PLE Plus...but the model runs!).
The stock solution generates a floating point overflow error each time the max value goes above zero (or for any initial value superior or equal to zero).
Thanks for your suggestions and your time.
Calculating ratio
hi tymoignee
I have tired to plot the error in my model but could not produce one.
Can you send me your model with the error so that I can try to find where there is a problem.
I have joined a model that generates stochastic values for the three parameters entered, and it works fine, whatever the values generated.
the initialization value for the stock is declared active initial, while it has to be calculated with auxiliaries prior to setting the inital value for the stock.
Regards.
J.J. Laublé
I have tired to plot the error in my model but could not produce one.
Can you send me your model with the error so that I can try to find where there is a problem.
I have joined a model that generates stochastic values for the three parameters entered, and it works fine, whatever the values generated.
the initialization value for the stock is declared active initial, while it has to be calculated with auxiliaries prior to setting the inital value for the stock.
Regards.
J.J. Laublé
- Attachments
-
- division by zero_2.mdl
- (3.03 KiB) Downloaded 533 times
Hi,
I attached the model.
I attached the model.
- Attachments
-
- Financial Fragility developed3.mdl
- (96.6 KiB) Downloaded 531 times
Divizion by zero
hi tymoignee
The model had an overflow because there was a parenthesis ill placed at the end of the formula, instead of just before.
Here is joined the corrected model.
Another remark.
I think that whatever you do with that model, it has a level of complexity that needs going to a more advanced version, at least Vensim Pro.
I worked too for a time with PLE plus, it has no subscripts and you get very quickly too highly complex sketches to the point that you do not master them anymore, which is critical for a useful model, not to mention the loss of time.
Another question.
Is your model a theoretical or scholar model, or is it destinated to be used in the real world?
Regards.
J.J. Laublé
The model had an overflow because there was a parenthesis ill placed at the end of the formula, instead of just before.
Here is joined the corrected model.
Another remark.
I think that whatever you do with that model, it has a level of complexity that needs going to a more advanced version, at least Vensim Pro.
I worked too for a time with PLE plus, it has no subscripts and you get very quickly too highly complex sketches to the point that you do not master them anymore, which is critical for a useful model, not to mention the loss of time.
Another question.
Is your model a theoretical or scholar model, or is it destinated to be used in the real world?
Regards.
J.J. Laublé
- Attachments
-
- financial_corrected.mdl
- (91.35 KiB) Downloaded 510 times
Thanks. It is a theoretical model for my thesis (will be developed during post doc).
I would like to have the pro version...but I am a student and it is way too expensive.
Hey! Vensim Guys! What about a student version...Come on!!!
Anyway, I can work out the complexity (the model is actually very simple) by using an accounting framework that makes sure that all the stocks and flows are consistent.
I would like to have the pro version...but I am a student and it is way too expensive.
Hey! Vensim Guys! What about a student version...Come on!!!
Anyway, I can work out the complexity (the model is actually very simple) by using an accounting framework that makes sure that all the stocks and flows are consistent.
Divizion by zero
I could have bet is was a theoretical model.
I mean by a theoretical model, a model that is not based on any observable reality and that will not have to pass the exam of calibration against real data.
These kind of models need a high level of mastering and understanding and are built progressively, checking regularly the concordence with real data.
But I understand your position. As a student you have to live with what you have and your examinators will certainly not be able to verify your conclusions.
But the good news are that SD works too with the real world, although I think that there are much more theoretical models
being built than real ones.
But you have to built a real world model, and to use it to be convinced of the fact.
Good luck with S.D. anyhow.
Regards.
J.J. Laublé
I mean by a theoretical model, a model that is not based on any observable reality and that will not have to pass the exam of calibration against real data.
These kind of models need a high level of mastering and understanding and are built progressively, checking regularly the concordence with real data.
But I understand your position. As a student you have to live with what you have and your examinators will certainly not be able to verify your conclusions.
But the good news are that SD works too with the real world, although I think that there are much more theoretical models
being built than real ones.
But you have to built a real world model, and to use it to be convinced of the fact.
Good luck with S.D. anyhow.
Regards.
J.J. Laublé
An academic license for Pro is already heavily discounted, by nearly 60%, what more can you ask forOriginally posted by tymoignee
I would like to have the pro version...but I am a student and it is way too expensive.
Hey! Vensim Guys! What about a student version...Come on!!!
![Wink ;)](./images/smilies/icon_wink.gif)
Lee