Ignoring overflows in SDE simulations

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm trying to compute the average of the solution to an SDE by simulating some of its sample paths and then taking their Mean. The problem is my SDE is explosive and about 1 in 10 calls to RandomFunction will result in an Overflow message. Since I need ~10k paths for the LLN to take effect and give me a reliable average, I am stuck. Here is a minimal working example:



proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
paths = RandomFunction[proc, 0., 5., 0.01, 10];
list[t_] := paths[t][[2]][[2]];
me[t_] := Mean[list[t]];
Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]


Even with 10 paths it will often get stuck on some explosive path, and on 100 paths it almost certainly will. I would like a way of running the simulation and throwing away paths that result in an Overflow. I'm thinking of something along the lines of a For loop with a Throw-Catch in it, but couldn't find anything similar on the internet and am completely stuck.



I'm aware that this would result in slightly a biased sample; my preference would have been to get it to plot the solution stopped when its absolute value hits some threshold, but this seems unattainable since ItoProcess seems not to care what process I ask it to output: even if I substitute the first line above with



proc = ItoProcess[0, x[t]^2, 1, x, 1, t, 0]


effectively asking it to output the constant 1, calls to RandomFunction will still crash with the same frequency. So I'll happily stick with just ignoring all the paths that result in an Overflow, unless of course there is a clever workaround.










share|improve this question







New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • "I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
    – Emilio Ferrucci
    1 hour ago










  • Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
    – Emilio Ferrucci
    1 hour ago














up vote
1
down vote

favorite












I'm trying to compute the average of the solution to an SDE by simulating some of its sample paths and then taking their Mean. The problem is my SDE is explosive and about 1 in 10 calls to RandomFunction will result in an Overflow message. Since I need ~10k paths for the LLN to take effect and give me a reliable average, I am stuck. Here is a minimal working example:



proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
paths = RandomFunction[proc, 0., 5., 0.01, 10];
list[t_] := paths[t][[2]][[2]];
me[t_] := Mean[list[t]];
Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]


Even with 10 paths it will often get stuck on some explosive path, and on 100 paths it almost certainly will. I would like a way of running the simulation and throwing away paths that result in an Overflow. I'm thinking of something along the lines of a For loop with a Throw-Catch in it, but couldn't find anything similar on the internet and am completely stuck.



I'm aware that this would result in slightly a biased sample; my preference would have been to get it to plot the solution stopped when its absolute value hits some threshold, but this seems unattainable since ItoProcess seems not to care what process I ask it to output: even if I substitute the first line above with



proc = ItoProcess[0, x[t]^2, 1, x, 1, t, 0]


effectively asking it to output the constant 1, calls to RandomFunction will still crash with the same frequency. So I'll happily stick with just ignoring all the paths that result in an Overflow, unless of course there is a clever workaround.










share|improve this question







New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • "I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
    – Emilio Ferrucci
    1 hour ago










  • Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
    – Emilio Ferrucci
    1 hour ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to compute the average of the solution to an SDE by simulating some of its sample paths and then taking their Mean. The problem is my SDE is explosive and about 1 in 10 calls to RandomFunction will result in an Overflow message. Since I need ~10k paths for the LLN to take effect and give me a reliable average, I am stuck. Here is a minimal working example:



proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
paths = RandomFunction[proc, 0., 5., 0.01, 10];
list[t_] := paths[t][[2]][[2]];
me[t_] := Mean[list[t]];
Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]


Even with 10 paths it will often get stuck on some explosive path, and on 100 paths it almost certainly will. I would like a way of running the simulation and throwing away paths that result in an Overflow. I'm thinking of something along the lines of a For loop with a Throw-Catch in it, but couldn't find anything similar on the internet and am completely stuck.



I'm aware that this would result in slightly a biased sample; my preference would have been to get it to plot the solution stopped when its absolute value hits some threshold, but this seems unattainable since ItoProcess seems not to care what process I ask it to output: even if I substitute the first line above with



proc = ItoProcess[0, x[t]^2, 1, x, 1, t, 0]


effectively asking it to output the constant 1, calls to RandomFunction will still crash with the same frequency. So I'll happily stick with just ignoring all the paths that result in an Overflow, unless of course there is a clever workaround.










share|improve this question







New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm trying to compute the average of the solution to an SDE by simulating some of its sample paths and then taking their Mean. The problem is my SDE is explosive and about 1 in 10 calls to RandomFunction will result in an Overflow message. Since I need ~10k paths for the LLN to take effect and give me a reliable average, I am stuck. Here is a minimal working example:



proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
paths = RandomFunction[proc, 0., 5., 0.01, 10];
list[t_] := paths[t][[2]][[2]];
me[t_] := Mean[list[t]];
Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]


Even with 10 paths it will often get stuck on some explosive path, and on 100 paths it almost certainly will. I would like a way of running the simulation and throwing away paths that result in an Overflow. I'm thinking of something along the lines of a For loop with a Throw-Catch in it, but couldn't find anything similar on the internet and am completely stuck.



I'm aware that this would result in slightly a biased sample; my preference would have been to get it to plot the solution stopped when its absolute value hits some threshold, but this seems unattainable since ItoProcess seems not to care what process I ask it to output: even if I substitute the first line above with



proc = ItoProcess[0, x[t]^2, 1, x, 1, t, 0]


effectively asking it to output the constant 1, calls to RandomFunction will still crash with the same frequency. So I'll happily stick with just ignoring all the paths that result in an Overflow, unless of course there is a clever workaround.







error stochastic-calculus






share|improve this question







New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 1 hour ago









Emilio Ferrucci

1084




1084




New contributor




Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Emilio Ferrucci is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • "I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
    – Emilio Ferrucci
    1 hour ago










  • Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
    – Emilio Ferrucci
    1 hour ago
















  • "I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
    – Emilio Ferrucci
    1 hour ago










  • Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
    – Henrik Schumacher
    1 hour ago










  • @HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
    – Emilio Ferrucci
    1 hour ago















"I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
– Henrik Schumacher
1 hour ago




"I'm aware that this would result in slightly a biased sample." Erm. I question that this would be only slightly biased if this happens once every ten times. Just image you would model a nuclear reaction in a civil nuclear power plant like this and what aftermath this could produce...
– Henrik Schumacher
1 hour ago












@HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
– Emilio Ferrucci
1 hour ago




@HenrikSchumacher Fair enough. I didn't want to give the full details of my problem, but basically the reason why I'm not too concerned about this is that I'm only interested in the asymptotics of the expectation in zero. I actually proved that these are not affected by modifying the SDE outside of a neighbourhood containing the initial condition, so explosions don't really affect what I'm interested in.
– Emilio Ferrucci
1 hour ago












Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
– Henrik Schumacher
1 hour ago




Then it would suffice to use a significantly smaller time horizon. For example, T = 0.1;paths = RandomFunction[proc, 0., T, T/50, 10000]; works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).
– Henrik Schumacher
1 hour ago












@HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
– Emilio Ferrucci
1 hour ago




@HenrikSchumacher Yes this is quite helpful, thank you. I guess I would have liked to have a way of systematically ignoring all explosions, and which allowed for an arbitrary time horizon. But this simple solution actually makes more sense theoretically. I can accept this as a solution if you post it.
– Emilio Ferrucci
1 hour ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










From you comment, I read off that you are actually interested only in the behavior close to $t = 0$.
Then it would suffice to use a significantly smaller time horizon. For example,



T = 0.1;
paths = RandomFunction[proc, 0., T, T/50, 10000];


works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).






share|improve this answer



























    up vote
    0
    down vote













    I have not necessarily fully understood your question, but one approach is to specify a higher working precision for RandomFunction e.g.



    proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
    paths = RandomFunction[proc, 0., 5., 0.01, 10, WorkingPrecision -> 30];
    list[t_] := paths[t][[2]][[2]];
    me[t_] := Mean[list[t]];
    Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]





    share|improve this answer




















      Your Answer




      StackExchange.ifUsing("editor", function ()
      return StackExchange.using("mathjaxEditing", function ()
      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
      );
      );
      , "mathjax-editing");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "387"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Emilio Ferrucci is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182857%2fignoring-overflows-in-sde-simulations%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote



      accepted










      From you comment, I read off that you are actually interested only in the behavior close to $t = 0$.
      Then it would suffice to use a significantly smaller time horizon. For example,



      T = 0.1;
      paths = RandomFunction[proc, 0., T, T/50, 10000];


      works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).






      share|improve this answer
























        up vote
        2
        down vote



        accepted










        From you comment, I read off that you are actually interested only in the behavior close to $t = 0$.
        Then it would suffice to use a significantly smaller time horizon. For example,



        T = 0.1;
        paths = RandomFunction[proc, 0., T, T/50, 10000];


        works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).






        share|improve this answer






















          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          From you comment, I read off that you are actually interested only in the behavior close to $t = 0$.
          Then it would suffice to use a significantly smaller time horizon. For example,



          T = 0.1;
          paths = RandomFunction[proc, 0., T, T/50, 10000];


          works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).






          share|improve this answer












          From you comment, I read off that you are actually interested only in the behavior close to $t = 0$.
          Then it would suffice to use a significantly smaller time horizon. For example,



          T = 0.1;
          paths = RandomFunction[proc, 0., T, T/50, 10000];


          works all fine for me. At least, this makes overflow less probable; maybe even impossible (reading from your comment, it seems that you have an argument that there is a positive minimal time until explosion).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Henrik Schumacher

          40.1k255120




          40.1k255120




















              up vote
              0
              down vote













              I have not necessarily fully understood your question, but one approach is to specify a higher working precision for RandomFunction e.g.



              proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
              paths = RandomFunction[proc, 0., 5., 0.01, 10, WorkingPrecision -> 30];
              list[t_] := paths[t][[2]][[2]];
              me[t_] := Mean[list[t]];
              Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]





              share|improve this answer
























                up vote
                0
                down vote













                I have not necessarily fully understood your question, but one approach is to specify a higher working precision for RandomFunction e.g.



                proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
                paths = RandomFunction[proc, 0., 5., 0.01, 10, WorkingPrecision -> 30];
                list[t_] := paths[t][[2]][[2]];
                me[t_] := Mean[list[t]];
                Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  I have not necessarily fully understood your question, but one approach is to specify a higher working precision for RandomFunction e.g.



                  proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
                  paths = RandomFunction[proc, 0., 5., 0.01, 10, WorkingPrecision -> 30];
                  list[t_] := paths[t][[2]][[2]];
                  me[t_] := Mean[list[t]];
                  Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]





                  share|improve this answer












                  I have not necessarily fully understood your question, but one approach is to specify a higher working precision for RandomFunction e.g.



                  proc = ItoProcess[0, x[t]^2, x[t], x, 1, t, 0]
                  paths = RandomFunction[proc, 0., 5., 0.01, 10, WorkingPrecision -> 30];
                  list[t_] := paths[t][[2]][[2]];
                  me[t_] := Mean[list[t]];
                  Plot[me[t], t, 0, 2, AxesOrigin -> 0, 0, AspectRatio -> 1, PlotRange -> 0, 2 0, 1]






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 28 mins ago









                  mikado

                  6,0671829




                  6,0671829




















                      Emilio Ferrucci is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      Emilio Ferrucci is a new contributor. Be nice, and check out our Code of Conduct.












                      Emilio Ferrucci is a new contributor. Be nice, and check out our Code of Conduct.











                      Emilio Ferrucci is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182857%2fignoring-overflows-in-sde-simulations%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery