Tag Info

New answers tagged

2

Using Event-Handling and Euler method Expanding the solution given by Michael E2 one might figure that using EventSeries is coming closest to the "real thing" which after all is a series of discrete events: eventTimes = Range[ 0, 10, 1 ]; (* example *) isEventTimeQ[ t_?NumericQ ] := Piecewise[ Table[ { 1 , t == eventTime }, {eventTime, eventTimes}], ...


4

I misunderstood and commented only about computing the Cesaro means as per the question In s I have all partial sums, but I do not know how to divide them by corresponding n. The desired scatter plot of 500 Monte Carlo attempts with samples of increasing length could be obtained with something like ticks = Range[-0.06, 0.06, 0.02]; s = Table[u = ...


4

In your example plot the Monte-Carlo integral is computed afresh for each new amount of sampling points: s[n_] := Total[Sqrt[1 - #^2] & /@ RandomReal[1, n]]/n Then take one random point, find the mean, take two new random points, find their mean, and so on until 500. The result is: ListPlot[Table[s[n], {n, 500}], PlotRange -> {0.7, 0.9}] The ...


5

First, you're not using a fixed step method. (An Euler scheme may be applied to any step size and to one that varies.) To get a true fixed step method you have to turn off "DiscontinuityProcessing" when you have a discontinuous ODE; otherwise, NDSolve will try to adapt the steps to account for the discontinuity. The "DiscontinuityProcessing" stage resets ...


0

This should generate 5000 samples from the distribution you specified, once you plug in the values of sigma and t: RandomVariate[ LogNormalDistribution[r - sigma^2/2, sigma Sqrt[t]], 5000 ] For instance (I just made up numbers here for mean and sigma): samples = RandomVariate[LogNormalDistribution[1 - 0.5^2/2, 0.5 Sqrt[2]], 1000]; Histogram[samples] ...


2

What you are missing, I believe, is sufficient experience of Mathematica's core language at the functional level that you experimenting with. I give you credit for making a good try at formulating your code in a functional way, but I'm afraid you gone somewhat wide of the mark. I have put your code into a form that works and which I think preserves your ...


4

The reason it's not finishing is that you set MaxSteps -> Infinity with a high AccuracyGoal. We can actually solve this system analytically, by replacing NDSolve with DSolve: qq = DSolve[{q'[t] == v[t]/r - q[t]/r*(1/c), q1'[t] == (((q[t] + q1[t])/(2*a*ϵ0*k2))*δ), q[0] == 10*10^-9, q1[0] == 10*10^-9}, {q, q1}, t]; We can inspect the solution: ...


2

Maybe you can try a matrix approach. 1/ The idea is to generate a matrix like this one : mat = {{a, 1, 0}, {b, 0, 1}, {c, 0, 0}}; then you can see that: {x1, x2, x3}.{{a, 1, 0}, {b, 0, 1}, {c, 0, 0}} {a x1 + b x2 + c x3, x1, x2} gives you the format you want. 2/ Then you can use that matrix directly in NestList (without the need to define a ...


0

Do it this way: With[{F= generater[parameters]}, model1[{x1_, x2_, x3_}] := F]; NestList[model1, {1, 1, 1}, 2]


-1

I had the same problem. But I found that this is probably because we changed the number of particles in the simulation. If you set numParticles = n*localSize, where n is an integer, the simulation works! localSize = 16 on my platform.



Top 50 recent answers are included