Tag Info

Hot answers tagged

13

You could use "PathComponents" property of TemporalData to split the vector-valued temporal data into the list of TemporalData objects and plot those: proc = ItoProcess[{{p[t], -p[t] - q[t]}, {{0}, {1}}}, {{q, p}, {0, 10}}, {t, 0}]; td = RandomFunction[proc, {0., 10., 0.02}, 10]; td["PathComponents"]


9

I'm not sure if I correctly understood what you want... However, I could read in the question that you want to simulate Ito Processes and, at the same time, to be able to change its parameters, especially the processes drifts and volatilities. In the comments I've read about the processes being correlated, so, let me try to put everything together in this ...


8

There are a couple of known bugs at play here. First, in TemporalData the date increment is given as a rational number but some of the underlying date functionality doesn't know how to handle this (e.g. DateList doesn't reliably cannonicalize date lists with fractional components). (*As of 9.0.1*) data = TemporalData[FinancialData["EUR/USD", {{2012, 5, 1}, ...


7

Although I have found ItoProcess an excellent tool in nearly all cases, in those situations where a correlation matrix is supplied to it ItoProcess incorrectly uses the Cholesky decomposition of the correlation matrix when it should actually be using the transpose of the Cholesky. Note that I discovered this bug back in December 2012 when I was looking at ...


7

I think it can be quite instructive to see how to integrate a stochastic differential equation (SDE) yourself. Of course there are different ways of doing that (a nice introduction is given in this paper). I chose the Euler-Maruyama method as it is the simplest one and is sufficient for this simple problem. Note that this assumes your SDE to be in Ito-form, ...


6

You can get the state values for every with data["States"], which you can then easily feed into a indicator function. data = RandomFunction[ GeometricBrownianMotionProcess[0.01, .15, 100], {0, 1, .01}, 100]; corridorIndicator[data_, upperBound_, lowerBound_] := Boole[Max@# < upperBound && Min@# > lowerBound] & /@ data ...


6

The number of players is relatively short, so we can brute-force the problem. There are only 8! = 40,320 different arrangements of players and it is easy enough to generate them all and then filter them: longList = (Sort /@ Partition[#, 2]) & /@ Permutations[Range@8]; Union[longList, SameTest -> (Or @@ Flatten[Outer[Equal, #1, #2, 1]] &)] ...


5

NExpectation[ Max[(S12 + S1)/2 - 100, 0], {S1, S12} \[Distributed] SliceDistribution[ GeometricBrownianMotionProcess[r, sigma, S0], {1/2, 1}], Method -> "MonteCarlo"] or NExpectation[ Max[(S12 + S1)/2 - 100, 0], {S1, S12} \[Distributed] SliceDistribution[ GeometricBrownianMotionProcess[r, sigma, S0], {1/2, 1}], Method -> {"NIntegrate", ...


4

Here is a faster way. I've only coded a portion of your problem to provide the flavor. Roll your own GBM GBMPathCompiled = Compile[{{S0, _Real}, {drift, _Real}, {diff, _Real}, {nSteps, _Integer}}, FoldList[(#1 drift Exp[ diff #2]) &, S0, RandomVariate[NormalDistribution[0, 1], nSteps]]]; Let's first visualize the situation Module[{S0 = ...


4

EDITED Alex, I believe this is what you want: StartingWealth = 100; PercentChange = 0.5; WinProbability = .5; NumberOfProcesses = 2; Time = 5; processes = RandomFunction[BinomialProcess[WinProbability], {0, Time}, NumberOfProcesses]; paths = Table[ FoldList[Times, StartingWealth, If[Differences[Last[Transpose[processes["Path", x]]]][[#]] == ...


4

You can set it up as a system of coupled equations : proc = ItoProcess[{\[DifferentialD]x[t] == y[t] \[DifferentialD]t, \[DifferentialD]y[t] == -(g/m y[t] + k/m x[t]) \[DifferentialD]t + Sqrt[2 kb bigT/(m^2 g)] \[DifferentialD]w[t]}, x[t], {{x, y}, {x0, y0}}, {t, 0}, w \[Distributed] ...


3

Please confirm if this is what you were looking for proc = ItoProcess[{{p[t], -p[t] - q[t]}, {{0}, {1}}, {q[t], p[t]}}, {{q, p}, {0, 10}}, {t, 0}]; data = RandomFunction[proc, {0, 10, 0.02}, 10]; You could do Plot[Through@data["PathFunction", All][t], {t, 0, 10}, Evaluated -> True]


2

Not sure I got your process right and not a very elegant solution : setup the process, do the simulations first, then look at the outcome. First off define your constraints : const[x_, y_] := And[10^-8 <= y <= 10^-3, 0.9*(Uc) <= a1*x^2 - a3*x^4/4 <= 1.1*(Uc)] I am outputting {t, x[t], y[t], Boole[const[x[t], y[t]]]} which contains all the ...


2

Change your process definition to: process = RandomFunction[Evaluate[win], {1, timstep}, samplepaths]; and you will avoid the first (zero) step. This is (I suspect) what Andy Ross was saying. The output of the above code (with the process defined as above) is the plot: which has all increasing values because the coefficient of the binomial is 0.99


2

Derivation of the Heston model from first principles using ItoProcess[ ] It's pleasantly surprising that something as subtle and useful as the Heston PDE can be easily derived via ItoProcess, once a few hurdles are overcome along the way. It's useful because, although the std Heston derivation is retold intuitively and in detail by Wilmott, by Shaw, by ...


2

Just a longer non-optimal alternative. This problem must have way cleaner solutions. I'll give it more thought in my sleep (or not) SetAttributes[{team, matchDay}, Orderless]; players = player /@ Range@8; There are only 7!!==105 possible match days you can build. One could build them up and then just find a combination in which every player plays only ...


2

Another way to visualize this is in the parametric phase space: ListLinePlot[td[[2, 1]], Frame -> True, AspectRatio -> 1, PlotRange -> All] ---------- Comment reponse ---------- We can check the structure of underlying expression with InputForm and then it is straightforward to use Part to extract the sub-expressions:


2

Possibly an overkill for this case but quite general : define a simple process which returns the variable you want procU = ItoProcess[\[DifferentialD]x[t] == \[DifferentialD]w[t], 1 + x[t]^2, {x, 0}, {t, 0}, w \[Distributed] WienerProcess[]] ; now you can use it as : Mean[procU[t]] (* 1 + t *) CovarianceFunction[procU, s, t] (* 2 Min[s, ...


1

Mathematica does not support Hypergeometric functions of matrix arguments. Currently only the cited paper by Plamen and Koev at http://math.mit.edu/~plamen/files/hyper.pdf contains a link to code that implements it in MATLAB.


1

Even though the result is not displayed the way one would expect, the distribution is there : PDF[SliceDistribution[ ItoProcess[\[DifferentialD]x[t] == -x[t] \[DifferentialD]t + \[DifferentialD]w[t], x[t], {x, 1}, t, w \[Distributed] WienerProcess[]], t], z] $$\frac{\exp \left(-\frac{e^t \left(z-e^{-t}\right) ...


1

You need to complete the specification of the driving process by providing an initial condition : SeedRandom[6] proc = ItoProcess[\[DifferentialD]x[t] == -x[t] \[DifferentialD]t + \[DifferentialD]w[t], x[t], {x, 1}, t, w \[Distributed] OrnsteinUhlenbeckProcess[0, 1, 1, 0]] RandomFunction[proc, {0., 5., 0.01}] ...


1

According to the documentation, it seems you just need to give values to L and Um (here 1) proc = ItoProcess[{\[DifferentialD]n[t] == Sqrt[(2)/(Pi)]*\[DifferentialD]w[t] - (\[DifferentialD]t*(n[t]))}, n[t], {n, 1}, t, Distributed[w, WienerProcess[]]]; now you can evaluate it f=RandomFunction[proc, {0., 5., 0.01}]; And visualize it ListLinePlot[f, ...


1

I'm not an expert on stochastic differential equations but I found the documentation clear enough. Getting the output in terms of a function of your process variable x[t] is easy: SeedRandom[1]; With[{σ = 1, μ = 1, x0 = 100}, proc = ItoProcess[ \[DifferentialD]x[t]/x[t] == σ \[DifferentialD]w[t] + μ \[DifferentialD]t, Log10[x[t]], ...


1

Thanks. I also found that there is a package with inbuilt functions, although super pricey, at http://scientificcomputing.blogspot.co.uk/2006/02/statistical-inference-package-for.html


1

Then, you must build the logic to handle the partial barriers. There are lots of ways to proceed. I modified the visualization to illustrate how indexing the sample times can be used to restrict the barrier penetration test and select those paths that survive the first barrier. Clear[PartialBarrierTest]; PartialBarrierTest[path_, iSt_, iFn_, U_, L_] := ...



Only top voted, non community-wiki answers of a minimum length are eligible