Tag Info

Hot answers tagged

16

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


15

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


11

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

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

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


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


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

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

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

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


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


5

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


5

As of version 10.0 there is a built in implementation of Random Forests which is accessible through the Classify function. trainingset = {1 -> "A", 2 -> "A", 3.5 -> "B", 4 -> "B"}; classifier = Classify[trainingset, Method->"RandomForest"];


5

How about this: s = Import["screw.obj"]; b = Import["board.obj"]; scr = First[s]; brd = First[b]; screwList = Table[{Hue[(5 i + j)/25], Translate[scr, {2 i - 1, RandomReal[{-.5, 2}], 1 - 2 j}]}, {i, 5}, {j, 5}]; Graphics3D[Join[{Brown, brd}, screwList],Lighting->"Neutral"] I added the board to the same Graphics3D as the screws, ...


4

You can check the book Bayesian Logical Data Analysis for the Physical Sciences there is also Mathematica notebooks for v7 and v8 under Other Files section.


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

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

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

This looks like a bug. May be you can send report to support@wolfram.com. I do not why it fails. Hard to debug using Trace. But it should work as is. I verified it using Maple symbolic control system functions and here is the result. I took Mathematica's A,B,C,D that came up from the state space, used them in Maple to create a state space, then converted ...


4

The requirement that la + lc == 100 is simple to implement, just pass 100 - la to Fc, or use ModelP/.{lc->100-la} in the call to FindFit. For the other trouble, remember that N is a special function in Mathematica, so avoid ever using this as a variable. Using n instead, I tried ModelP = (2/q^4)*Re[((1 - Fc[q, lc, sc])*(1 - Fa[q, la, sa]))/ (1 - ...


3

I am not so sure that this is an unreasonable forecast given the model structure you have assumed. Mathematica does not make it easy to extract fitted values from the model using the model["SomeProperty'] construct, which is a pity. (Or maybe I missed that bit in the documentation.) When you check the best fit model, it is clear that the seasonal MA ...


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


3

Maybe this will help. It's a collection of macro growth theory solved in Mathematica


3

The most direct way, but undocumented and therefore subject to change in future versions, is to use a Library function: In: Reliability`Library`StructureFunction[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

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


3

The input form of $spacecraft$ is the following: StateSpaceModel[{{{0, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}}, {{0, 0}, {1/m, 0}, {0, 0}, {0, 1/m}}, {{1, 0, 0, 0}, {0, 0, 1, 0}}, {{0, 0}, {0, 0}}}, {{x[t], 0}, Subscript[\[FormalX], 1], {y[t], 0}, Subscript[\[FormalX], 2]}, {{u1[t], 0}, {u2[t], 0}}, Automatic, t, SamplingPeriod -> ...



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