# Tag Info

14

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 ...

14

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]}], ...

12

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 ...

7

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 ...

7

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

Yes you can, for example: thrust[t_, t0_: 1000] := 34020.000 UnitStep[t0 - t] end = 10000 soln = Table[ NDSolve[{ x''[t] == -((G M x[t])/Norm[{x[t], y[t], z[t]}]^3), y''[t] == -((G M y[t])/Norm[{x[t], y[t], z[t]}]^3) + 0.25 thrust[t, t0]/m, z''[t] == -((G M z[t])/Norm[{x[t], y[t], z[t]}]^3) + 0.75 thrust[t, ...

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

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 ...

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 ...

6

Standard errors and confidence intervals from linear and nonlinear regressions are obtained from the covariance matrix. Details about the covariance matrix can be obtained here. Briefly, the square root of the diagonal elements of the covariance matrix gives us the standard errors: se = Sqrt[nlm["CovarianceMatrix"]] // Diagonal (* {1.10159, 0.600123} *) ...

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}, ...

4

In the scalar approximation, the obstacle could be modeled by an abrupt change in the wave speed $c$. This speed is unity in your original calculation, and I'm just going to insert its inverse square as a prefactor in front of the second time derivative. The spatial shape is defined as an elongated box using Boole: tsunamiEqn = u /. NDSolve[{(1/(1 - ...

4

A bit puzzling, but I think you have problems with the levels in ListLogPlot (where you added another set of values), and with the PlotStyle directives (where you added options to a Directive). I changed a few things quasi-randomly and got something which I think is closer to what you want. Manipulate[ SeedRandom[seed]; Column[{ test2[μ_, σ_, S_, P_] ...

4

There is an alternative solution to implement AMD into Mathematica, by using the MinCut function from the GraphUtilities Package. This function is not just working on Graphs but is also usable for Matrices. The algorithm is reordering the Matrix into blocks and effectively reducing the off diagonal elements. It can be involved rather easily. If one starts ...

3

The most direct way, but undocumented and therefore subject to change in future versions, is to use a Library function: In: ReliabilityLibraryStructureFunction[bexpr2] Out: c1 c3 ((1 - c5) (-1 + c6) - (1 - c2 c5) (-1 + c4 c6)) c7 + c1 (1 + (1 - c2 c5) (-1 + c4 c6)) c7 Use Expand if you would like the simpler structure showing the cutsets in a clearer ...

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

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, ...

2

There is an open-source Modelica system called OpenModelica at www.openmodelica.org. Frankly, I am a little baffled at what you are calling a "downside". Modelica is an object oriented language, so only different classes need to be defined within the library. A single class can be implemented as many objects within your model. For example, a resistor ...

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}]

2

Possibly you want to convert to "algebraic normal form" and, from there, to a boolean algebra expression in terms of plus and times. path1 = And[c1, c2, c5, c7]; path2 = And[c1, c3, c5, c7]; path3 = And[c1, c3, c6, c7]; path4 = And[c1, c4, c6, c7]; bexpr2 = BooleanConvert[Or[path1, path2, path3, path4], "ANF"] (* Out[25]= (c1 && c2 && c5 ...

2

I had to make a number of corrections and adjustments to the code, but here is the idea. TestSystem = {h'[t] == p - h[t] (k1 sh[t]), h[0] == H0, sh'[t] == -k1 h[t] sh[t] + k2 ss[t], sh[0] == sh0, st == sh[t] + ss[t]}; TestSolver[H0e_, st0_] := ParametricNDSolve[ TestSystem /. p -> 0 /. {H0 -> H0e} /. sh0 -> st0 /. st -> st0 /. ...

2

While the MinCut (and also the MinimumBandwidth command in the GraphUtilities package) may be useful in many situations, this is a very general problem and might also benefit from more general solutions. For example, a while ago I had some data about the relationship between 120 items in the form of a distance matrix, basically a measurement of the distance ...

2

Finally I got a feedback from Wolfram support on the AMD algorithm. It turned out that there is (almost as usual) an undocumented implementation of the AMD algorithm within Mathematica. The algorithm is exactly identical to the MATLAB implementation, thus exactly what I was looking for. By calling SparseArray`ApproximateMinimumDegree[m_Matrix] one gets ...

2

temp = WeatherData["Chicago", "Temperature", {{1990}, {2010}, "Month"}]; data = temp /. {{y_, m_, d_}, x_} :> {m, x}; lm = LinearModelFit[data, {1, x, x^2, x^3, x^4}, x] Show[ListPlot[data, PlotRange -> All, Frame -> True], Plot[lm[x], {x, 0, 13}]] But I would personally go for something like this: data1 = Join[data, {12, 0} + # & ...

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