Driving a system of differential equations with an AR1-Process

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











up vote
2
down vote

favorite












I have the following system of differential equations:



v[t_] := RandomVariate[NormalDistribution];
sol = NDSolve[x1'[t] == -0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] -
1.22 x4[t] + v[t],
x2'[t] ==
0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t] + v[t],
x3'[t] ==
0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t] + v[t],
x4'[t] ==
0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t] + v[t],
x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x1, x2, x3,
x4, t, 0, 60];
graphAll =
Plot[Evaluate[x1[t], x2[t], x3[t], x4[t] /. sol], t, 0, 60,
PlotRange -> All]


I want to drive the system with an AR1-Process. So far I was only able to specify some random variate from a normal distribution, but it does not seem to work properly.



Any ideas how to do this?










share|improve this question

























    up vote
    2
    down vote

    favorite












    I have the following system of differential equations:



    v[t_] := RandomVariate[NormalDistribution];
    sol = NDSolve[x1'[t] == -0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] -
    1.22 x4[t] + v[t],
    x2'[t] ==
    0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t] + v[t],
    x3'[t] ==
    0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t] + v[t],
    x4'[t] ==
    0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t] + v[t],
    x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x1, x2, x3,
    x4, t, 0, 60];
    graphAll =
    Plot[Evaluate[x1[t], x2[t], x3[t], x4[t] /. sol], t, 0, 60,
    PlotRange -> All]


    I want to drive the system with an AR1-Process. So far I was only able to specify some random variate from a normal distribution, but it does not seem to work properly.



    Any ideas how to do this?










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have the following system of differential equations:



      v[t_] := RandomVariate[NormalDistribution];
      sol = NDSolve[x1'[t] == -0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] -
      1.22 x4[t] + v[t],
      x2'[t] ==
      0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t] + v[t],
      x3'[t] ==
      0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t] + v[t],
      x4'[t] ==
      0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t] + v[t],
      x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x1, x2, x3,
      x4, t, 0, 60];
      graphAll =
      Plot[Evaluate[x1[t], x2[t], x3[t], x4[t] /. sol], t, 0, 60,
      PlotRange -> All]


      I want to drive the system with an AR1-Process. So far I was only able to specify some random variate from a normal distribution, but it does not seem to work properly.



      Any ideas how to do this?










      share|improve this question













      I have the following system of differential equations:



      v[t_] := RandomVariate[NormalDistribution];
      sol = NDSolve[x1'[t] == -0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] -
      1.22 x4[t] + v[t],
      x2'[t] ==
      0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t] + v[t],
      x3'[t] ==
      0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t] + v[t],
      x4'[t] ==
      0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t] + v[t],
      x1[0] == 0, x2[0] == 0, x3[0] == 0, x4[0] == 0, x1, x2, x3,
      x4, t, 0, 60];
      graphAll =
      Plot[Evaluate[x1[t], x2[t], x3[t], x4[t] /. sol], t, 0, 60,
      PlotRange -> All]


      I want to drive the system with an AR1-Process. So far I was only able to specify some random variate from a normal distribution, but it does not seem to work properly.



      Any ideas how to do this?







      differential-equations random-process






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 46 mins ago









      holistic

      1,165620




      1,165620




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          You need to use RandomFunction[ItoProcess] instead of NDSolve. The syntax is a frustratingly a little different than NDSolve. Driven by a WienerProcess as in your example:



          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == [DifferentialD]v[t] +
          (-0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == [DifferentialD]v[t] +
          (0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] +0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == [DifferentialD]v[t] +
          (0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == [DifferentialD]v[t] +
          (0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          x1[t], x2[t], x3[t], x4[t], x1, x2, x3, x4, 0, 0, 0, 0, t,
          v [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol, PlotRange -> All]


          Mathematica graphics



          For the AR-1 part, I think you need to add a first-order decay equation for v[t] driven by a WienerProcess like:



          ϕ = 1;
          σ = 1;
          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == (v[t] - 0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == (v[t] + 0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == (v[t] + 0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == (v[t] + 0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          [DifferentialD]v[t] == -ϕ v[t] [DifferentialD]t + σ [DifferentialD]W[t],
          x1[t], x2[t], x3[t], x4[t], v[t], x1, x2, x3, x4, v, 0, 0, 0, 0, 0, t,
          W [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol]


          Mathematica graphics






          share|improve this answer






















          • @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
            – Chris K
            12 mins ago











          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
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184537%2fdriving-a-system-of-differential-equations-with-an-ar1-process%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          You need to use RandomFunction[ItoProcess] instead of NDSolve. The syntax is a frustratingly a little different than NDSolve. Driven by a WienerProcess as in your example:



          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == [DifferentialD]v[t] +
          (-0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == [DifferentialD]v[t] +
          (0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] +0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == [DifferentialD]v[t] +
          (0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == [DifferentialD]v[t] +
          (0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          x1[t], x2[t], x3[t], x4[t], x1, x2, x3, x4, 0, 0, 0, 0, t,
          v [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol, PlotRange -> All]


          Mathematica graphics



          For the AR-1 part, I think you need to add a first-order decay equation for v[t] driven by a WienerProcess like:



          ϕ = 1;
          σ = 1;
          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == (v[t] - 0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == (v[t] + 0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == (v[t] + 0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == (v[t] + 0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          [DifferentialD]v[t] == -ϕ v[t] [DifferentialD]t + σ [DifferentialD]W[t],
          x1[t], x2[t], x3[t], x4[t], v[t], x1, x2, x3, x4, v, 0, 0, 0, 0, 0, t,
          W [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol]


          Mathematica graphics






          share|improve this answer






















          • @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
            – Chris K
            12 mins ago















          up vote
          3
          down vote













          You need to use RandomFunction[ItoProcess] instead of NDSolve. The syntax is a frustratingly a little different than NDSolve. Driven by a WienerProcess as in your example:



          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == [DifferentialD]v[t] +
          (-0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == [DifferentialD]v[t] +
          (0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] +0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == [DifferentialD]v[t] +
          (0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == [DifferentialD]v[t] +
          (0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          x1[t], x2[t], x3[t], x4[t], x1, x2, x3, x4, 0, 0, 0, 0, t,
          v [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol, PlotRange -> All]


          Mathematica graphics



          For the AR-1 part, I think you need to add a first-order decay equation for v[t] driven by a WienerProcess like:



          ϕ = 1;
          σ = 1;
          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == (v[t] - 0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == (v[t] + 0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == (v[t] + 0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == (v[t] + 0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          [DifferentialD]v[t] == -ϕ v[t] [DifferentialD]t + σ [DifferentialD]W[t],
          x1[t], x2[t], x3[t], x4[t], v[t], x1, x2, x3, x4, v, 0, 0, 0, 0, 0, t,
          W [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol]


          Mathematica graphics






          share|improve this answer






















          • @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
            – Chris K
            12 mins ago













          up vote
          3
          down vote










          up vote
          3
          down vote









          You need to use RandomFunction[ItoProcess] instead of NDSolve. The syntax is a frustratingly a little different than NDSolve. Driven by a WienerProcess as in your example:



          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == [DifferentialD]v[t] +
          (-0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == [DifferentialD]v[t] +
          (0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] +0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == [DifferentialD]v[t] +
          (0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == [DifferentialD]v[t] +
          (0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          x1[t], x2[t], x3[t], x4[t], x1, x2, x3, x4, 0, 0, 0, 0, t,
          v [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol, PlotRange -> All]


          Mathematica graphics



          For the AR-1 part, I think you need to add a first-order decay equation for v[t] driven by a WienerProcess like:



          ϕ = 1;
          σ = 1;
          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == (v[t] - 0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == (v[t] + 0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == (v[t] + 0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == (v[t] + 0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          [DifferentialD]v[t] == -ϕ v[t] [DifferentialD]t + σ [DifferentialD]W[t],
          x1[t], x2[t], x3[t], x4[t], v[t], x1, x2, x3, x4, v, 0, 0, 0, 0, 0, t,
          W [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol]


          Mathematica graphics






          share|improve this answer














          You need to use RandomFunction[ItoProcess] instead of NDSolve. The syntax is a frustratingly a little different than NDSolve. Driven by a WienerProcess as in your example:



          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == [DifferentialD]v[t] +
          (-0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == [DifferentialD]v[t] +
          (0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] +0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == [DifferentialD]v[t] +
          (0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == [DifferentialD]v[t] +
          (0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          x1[t], x2[t], x3[t], x4[t], x1, x2, x3, x4, 0, 0, 0, 0, t,
          v [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol, PlotRange -> All]


          Mathematica graphics



          For the AR-1 part, I think you need to add a first-order decay equation for v[t] driven by a WienerProcess like:



          ϕ = 1;
          σ = 1;
          sol = RandomFunction[ItoProcess[
          [DifferentialD]x1[t] == (v[t] - 0.33 x1[t] - 1.13 x2[t] - 1.84 x3[t] - 1.22 x4[t]) [DifferentialD]t,
          [DifferentialD]x2[t] == (v[t] + 0.15 x1[t] - 0.57 x2[t] + 0.29 x3[t] + 0.28 x4[t]) [DifferentialD]t,
          [DifferentialD]x3[t] == (v[t] + 0.24 x1[t] + 0.34 x2[t] - 0.48 x3[t] + 0.38 x4[t]) [DifferentialD]t,
          [DifferentialD]x4[t] == (v[t] + 0.17 x1[t] + 0.18 x2[t] + 0.32 x3[t] - 0.56 x4[t]) [DifferentialD]t,
          [DifferentialD]v[t] == -ϕ v[t] [DifferentialD]t + σ [DifferentialD]W[t],
          x1[t], x2[t], x3[t], x4[t], v[t], x1, x2, x3, x4, v, 0, 0, 0, 0, 0, t,
          W [Distributed] WienerProcess[0, 1]], 0, 100, 0.01];
          ListLinePlot[sol]


          Mathematica graphics







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 12 mins ago

























          answered 29 mins ago









          Chris K

          5,82221738




          5,82221738











          • @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
            – Chris K
            12 mins ago

















          • @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
            – Chris K
            12 mins ago
















          @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
          – Chris K
          12 mins ago





          @MariuszIwaniuk Yeah I made a few mistakes in the AR(1) part and also missed a couple commas -- could you try again?
          – Chris K
          12 mins ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184537%2fdriving-a-system-of-differential-equations-with-an-ar1-process%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