# Tag Info

15

I first create the plot with GridLines -> Automatic: plot = Plot[-Sin[x], {x, -10, 0}, PlotRange -> {{-10, 1}, {-1.1, 1.1}}, ImageSize -> {500, 100}, Axes -> False, GridLines -> Automatic] Then I combine your graphics object with plot using Inset: Manipulate[ Graphics[{Circle[], PointSize[0.012], Point[{Cos[t], Sin[t]}], ...

13

I think the simple answer is, there isn't one, but you could always just use UML itself, particularly for behavioral diagrams, even if the code isn't object oriented. You wouldn't use class or object diagrams, but there is nothing to stop you from using, say, a component diagram. You may find the tutorial and white paper on building large software systems ...

10

Here I will attempt to provide a basic implementation of the random forest algorithm for classification. This is by no means fast and doesn't scale very well but otherwise is a nice classifier. I recommend reading Breiman and Cutler's page for information about random forests. The following are some helper functions that allow us to compute entropy and ...

10

Disclaimer: This is not an implementation of the Random Forest Algorithm. Also, while I have on occasion used random florists, until today I had not heard of the Random Forest Algorithm. I poked around a bit on the Net and learned that these take subsamples of data, subsampling the variables as well, and form decision trees for the subsetted subsamples. ...

7

The answer to the more general question of how necessary "software architecturizationing" is in Mathematica is, in short: Not that necessary. The reason is basically 1) lists 2) dynamic typing and 3) lists + dynamic typing. For example, Mathematica doesn't need classes/OO because lists allow you to represent a huge swath of data structures. You would gain ...

6

Here's a "compositional" approach. If you take things piece-by-piece it is not too hard to build up more complicalated demonstrations. Animate[Module[ {spazzyP, scrollingPaper, scrollingSine, circle, pCoords, yCoords, yellowDot, blueLine, offset = 1, range = 2 Pi, padding = 1, fmin = Floor[min]}, pCoords = {min + offset - Cos[min + offset], ...

6

I haven't thought about this for delay differential equations, but for initial value problems, you can just think of the perturbation as a new initial value problem, then the only issue is stitching together the interpolating functions with Witch. Since you mention predator-prey systems lets use logistic growth as the example: sol1 = First@With[{r = 0.5, k ...

6

Since you don't sem to have any explicit forward-looking / rational expectations elements in your system (the equation for Pie depends only on lags), I don't know why you are expressing your time subscripts as $T+2$ rather than $t$, $t-1$, $t-2$. Your system is essentially linear, so I would suggest that you define your system as a vector state variable ...

6

I'm going to be bold and attempt to edit the Ross code so that it is (a) a little easier to understand and (b) takes the same form of argument as LinearModelFit and other Mathematica prediction creators. I've also added some annotations to the critical code. My variable names are now far longer than the Ross names but perhaps for informative. So far in my ...

5

Same kind of approach as @einbandi's here but without insetting and the grid: Manipulate[ plot = Plot[-Sin[x - t], {x, 0, 10}, PlotRange -> {{-10, 1}, {-1.1, 1.1}}, ImageSize -> {500, 100}, Axes -> False, PlotStyle -> Blue]; line = Graphics@Line[{{0, Sin[t]}, {Cos[t], Sin[t]}}]; circle = ...

4

Now that Mathematica has added WhenEvent we have the super sweet solution that requires non of this ugly boiler plate. For the single perturbation case we have the following: Module[{r = 0.5, k = 10, x0 = 5, perturb, sol}, perturb = WhenEvent[Mod[t, 200], x[t] -> 1.1 x[t]]; sol = NDSolveValue[{{x'[t] == r x[t] (1.0 - x[t]/k), x[0] == x0}, perturb}, ...

3

The limitation you quote is not a general limitation of Modelica. It is possible to define a Modelica component that has a variable number of inputs/outputs. Typically the number of inputs/outputs is then given by a parameter to that component. For example, the following component has one input but 2 outputs, varied with the parameter nout: model SIMO ...

3

I very much enjoy Dan's approach in part because it is so simple both in concept and implementation. I'm taking the liberty here of suggesting a few arguable improvements to his terrific code. For makeForest (a) the data is in the same format as is used in functions such as LinearModelFit (a simple array instead of a list of rules of features onto class); ...

3

This might not be the canonical way, but the way I would do it is to represent the system as a pair of state-updating equations, translate that into matrix form and use NestList to show the time path. This is of course assuming that you are happy to work in discrete time. Consider, for example, where the reproduction rate at time $t$ is a positive function ...

2

Of course the true exponential function is the solution of a differential equation in which the time steps are taken to be infinitesimal. However, it seems like you're looking for an implementation that's as literal as possible and uses discrete time steps: coli[rate_, nStart_, n_] := NestList[Function[{coli}, Round[coli + rate coli]], nStart, n] ...

2

I'd like to extend the solution offered by Michael E2: psol = ParametricNDSolve[{A'[t] == k1*A[t], A[0] == 10, WhenEvent[t < 10, k1 -> (k1 + s)], WhenEvent[t < 20, k1 -> (k1 - s)]}, A, {t, 0, 100}, {k1 \[Element] Reals, s \[Element] Reals}]; (*Plot[Evaluate[A[0.1, 0.2][t] /. psol], {t, 0, 30}]*) Note that even in the case the DE ...

2

You don't need WhenEvent[] for this: Manipulate[Plot[(A/. NDSolve[{A'[t] == (k1 + s HeavisidePi[1/10 (t - 15)]) A[t], A[0] == 10}, A, {t, 0, 100}] [[1]] )[x], {x, 0, 30}], {k1, 0.0, 1.0}, {s, 0.0, 1.0}]

1

I don't think you can use WhenEvent to do what you want. The value of k1 is passed in the DE in NDSolve, not the symbol. WhenEvent has the attribute HoldAll, so that it deals with k1 and s as Symbols. Perhaps you could use ParametricNDSolve (see below). Perhaps you want something like this? kparam[t_?NumericQ, k1_, s_] := If[10 < t < 20, k1 + s, ...

1

Gabriel, your answer really helped. I think I've implemented the functionality I was going for: Manipulate[ System = First@ With[{d = delay, a = multiplier, y0 = deviation}, NDSolve[{y'[time] + a*y[time - d] == 0, y[time /; time <= 0] == y0}, y, {time, 0, timePerturbed}]]; PerturbedSystem = First@Module[{d = delay, a = multiplier, ...

1

The answer is that there is a problem with your model. Before about 1952.5, it is growing sub-exponentially. Then it suddenly collapses. plot = LogPlot[B[t] /. model[[1]], {t, 1950, 1970}] Because the values go negative, it is not even possible to use LogPlot to reveal these data. Table[B[i] /. model[[1]], {i, 1954, 1960}] {-1.58056*10^16, ...

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