Tag Info

New answers tagged

1

As noted in my comment, you can use much more efficient built-ins to accomplish this, e.g. data = RandomFunction[GeometricBrownianMotionProcess[0.3693, 0.16689, 78.55], {0, .5, 0.001}, 50]; ListPlot[data["Paths"], Joined -> True] Should be orders of magnitude faster generating your random data...


0

As glance as answered you could just create a table with multiplicity of desired runs. I may have miscoded your intentions but I think you could also do as follows: bm[x_, m_, s_, t_, h_] := Module[{d = Sqrt@h, n = t/h, g, sm, gm}, g = RandomVariate[NormalDistribution[0, d], n]; sm = Accumulate[Prepend[g, 0]]; gm = MapIndexed[ x Exp[(m - s^2/2) ...


0

What about this? Brownian[x0_, \[Mu]_, \[Sigma]_, t_, h_] := Module[{d = Sqrt[h], m = t/h,g,sums,X}, g = Table[Random@NormalDistribution[0, d], {m}]; sums = FoldList[Plus, 0, g]; Do[X[i] = sums[[i + 1]], {i, 0, m}]; Table[x0*E^((\[Mu] - \[Sigma]^2/2)*i*h + \[Sigma]*X[i]), {i, 0, m}] ] m = 500; h = .001; gList = Table[ geometric = ...


4

Remember that = is really Set, and Set is a pretty ordinary function. Also, RandomInteger can make a list all by itself, so you don't need Table. r = {a, b, c, d, e, f, g, h, i}; MapThread[Set, {r, RandomInteger[{0, 20}, Length[r]]}];


1

As Fred Simons comments NIntegrate has the HoldAll attribute but alone that does not explain this behavior. With the literal assignment z = 1 no NIntegrate::nlim message prints: z = 1; NIntegrate[f[x], {x, 0, z}] Table normally works by the same mechanism as Block, and indeed we see the same behavior from Block: ClearAll[f, x, z] Block[{z = 1}, ...


6

Table[k1 + k2, Evaluate@{ToExpression[list[[1]]], 1, 2}, Evaluate@{ToExpression[list[[2]]], 1, 2}] (* {{2, 3}, {3, 4}} *) Or Table[k1 + k2, {#, 1, 2}, {#2, 1, 2}] & @@ ToExpression[list] (* {{2, 3}, {3, 4}} *)


1

Here's an answer to the question in the comments below OP: grid={{{{0, 1, 2}, {0, 1, 3}}, {{0, 2, 2}, {0, 2, 3}}}, {{{1, 1, 2}, {1, 1, 3}}, {{1, 2, 2}, {1, 2, 3}}}} A 2x2x2 list of 3-component vectors. If I understood correctly, pick out, for example, all such vectors, that have 0 as their first component. I am inclined to take a pattern-matching ...


2

Pick[#[[All, {1, 3}]], #[[All, 2]], 1] & @@@ grid (* {{{0, 2}, {0, 3}}, {{1, 2}, {1, 3}}} *) or (Select[#, #[[2]] == 1 &] & @@@ grid)[[All, All , {1, 3}]] (* {{{0, 2}, {0, 3}}, {{1, 2}, {1, 3}}} *) or Cases[grid, m : {{_, 1, _} ..} :> m[[All, {1, 3}]], {2}] (* {{{0, 2}, {0, 3}}, {{1, 2}, {1, 3}}} *) Update: You can also turn the ...


3

Have a look at the documentation for CSV. The first issue you have is that your file extension is .txt so Mma imports it as text file instead of a CSV file. Your second issue is that "Table" is not a supported element for either CSV or TXT so I think it is just being ignored. Even though your file does not have the .csv file type you can still tell Mma ...


0

EDIT: Corrections VBA to Mathematica code translation optval[vol_, intrate_, expn_, payoff_, strike_, Etype_, NAS_] := Module[{S, vold, Vnew, Dummy, ds, dt, NTS, q, gamma, Delta, Theta}, S = Table[0, {NAS + 1}]; vold = Table[0, {NAS + 1}]; Vnew = Table[0, {NAS + 1}]; Dummy = Table[0, {NAS + 1}, {3}]; ds = 2*strike/NAS; dt = 0.9/vol^2/NAS^2; ...


0

ClearAll[t, al]; set[t_, al_] := {{Cos[t], al + Sin[t]}, {2 Cos[al] + Cos[t], 2 Sin[al] + Sin[t]}, {al, t}}; ParametricPlot[set[t, al], {t, 0, 2 \[Pi]}, {al, 1, 2}, PlotRange -> All] Table[set[1., al], {al, 0, 2. \[Pi] - \[Pi]/36, \[Pi]/36.}] // TableForm Taking one parameter only in the Table, it works.


4

On further look, your ParametricPlot expression is a bit odd. You have something like : ParametricPlot[{ f[t] , g[t] , h[r] } , {t,trange} , {r,rrange } .. ] By supplying ParametricPlot with two independent variables it thinks you want to plot regions, yet none of your functions depends on both variables. Try this: testpara[\[Alpha]_] := Show[{ ...



Top 50 recent answers are included