43

I'm one of the developers behind this functionality, so I might be biased, but in my opinion this does provide a huge new feature set to Mathematica users. What practical use do these new functions have for those who don't have the full SystemModeler? The new functions provide a sophisticated analysis environment for system modeling. They do that stand-...


28

This kind of backtest is often performed using approximations, for instance with normal distributions, which may not be always valid. An exact test would be very nice to have. The probability distribution that is necessary to describe this process is the so-called Poisson Binomial distribution. It describes the sum of independent Bernoulli experiments ...


24

Similar to previous answers, only I don't make the instantaneous absorption assumption since it isn't really necessary. The equation can be found here on page three, where ka and ke are the rates of absorption and elimination, respectively, D is the initial dose (in ng), V/F is the Volume of Distribution. The range of apparent volumes of distribution I've ...


21

Modified Newton Cooling Law implementation and reduced FEA cell length Clear["Global`*"] len = 1;(*length of domain*) end = 5;(*end time*) h = 2;(*convection coefficient*) cpmR = 9;(*heat capacity/mass ratio*) Tinit = 0;(*initial temperature of the bar*) T0init = 100;(*initial temperature of the fluid*) (*Tsol=temperature in the bar,T0sol=temperature on ...


16

First let me observe that your coding style makes debugging difficult, I highly recommend breaking giant expressions into manageable pieces. Second, in the code below I have used a different definition for the segments. Your version: $y=(x-x_1)^{curvature}\frac{y_2-y_1}{x_2-x_1}+y_1$ does not give an amplitude of $y_2$ at $x=x_2$ if $curvature\neq1$. I ...


14

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


14

Assuming the simplest kinetic model for elimination (and making the simplifying assumption of "instant absorption" to peak concentration): conc = {{0, 0}, {.25, 1}, {.5, 7}, {1, 26}, {1.5, 40}, {2, 45}, {2.5, 45}, {3, 44}, {3.5, 44}, {4, 43}, {4.5, 41}, {5, 39}, {6, 38}, {7, 37}, {8, 35}, {9, 33}, {10, 32}, {11, 29}, {12, 24}, {24, 13}, {48, ...


14

Perhaps have a look at DiscreteMarkovProcess using an appropriate transition matrix embedding your constraints? Here's a simple example, implementing 1-5 above, to get you started: transitionMatrix = { {0, 0, 1/2, 0, 1/2, 0, 0}, {6/10, 0, 4/10, 0, 0, 0, 0}, {1/2, 0, 0, 0, 1/2, 0, 0}, {0, 0, 1, 0, 0, 0, 0}, {1/2, 0, 1/2, 0, 0, 0, 0}, {0, 0, ...


12

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} *) ...


12

Consider a model where the nonlinearity is in $x'(t)$ and not in the highest derivative $x''(t)$. eq1 = {x''[t] + Sin[ x'[t]] + x[t] == u[t]}; Choose the first state as $x(t)$ (call it $\bar{x}_1(t)$) and the second state as $x'(t)$ (call it $\bar{x}_2(t)$) and we get the following equations. $$ \bar{x}_1'(t)=\bar{x}_2(t)$$ $$ \bar{x}_2'(t)+\sin \left(\...


12

Mimicking the examples in FindFit >> Applications >> DifferentialEquations NonlinearModelFit >> Generalizations and Extensions ClearAll[x, y, b, β, model] b0 = .7; sol = First[y /. NDSolve[{y''[x] + Sin[y[x]] + b0 y'[x] == 0, y[0] == 1.5, y'[0] == 0}, y, {x, 0, 3 Pi}]]; xvals = N[Range[0, 3 Pi, 3 Pi/100]]; data = Transpose[{xvals, sol[xvals] + ...


12

First question. I'm pretty sure that the difference is due to what happens with machine underflow. As of V11.3, underflow goes to machine zero instead of to arbitrary-precision numbers (as it does in versions < 11.3). See (94996), (169361), (174587). Try SetSystemOptions["CatchMachineUnderflow" -> False] in versions < 11.3 to see if it will prevent ...


12

OK. Let me extend my comments to an answer. First of all, I'd like to point out why OP's attempt doesn't work: "NDSolveValue should return a list with three elements." No, NDSolveValue already fails after the first warning, what's returned is an unevaluated NDSolveValue[…]. If you still feel confused, execute the NDSolveValue[…] separately and ...


11

The following code simulates the Biham-Middleton-Levin traffic model for 1000 iterations using explicit rules. According to Wikipedia the blue and red cars take turns to move, which means each step is simpler than what you implemented, however. Simulating cellular automata with better performance has been dealt with here and here. (I've contributed to both.)...


11

You have to use ColorNegate and other image processing functions to make the area that you want to sample is white, while the rest is black. After that you can use ImageMesh and RandomPoint like this: img = Import["https://i.stack.imgur.com/J2JQK.png"]; mesh = ImageMesh[ColorNegate[img]]; pts = RandomPoint[mesh, 500]; Show[mesh,ListPlot[pts, PlotStyle -&...


10

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"];


10

I have no experience with what you are trying to do so this is entirely guesswork but maybe you want something like this? cmaxd = Interpolation[dmethyl1, InterpolationOrder -> 1]; f1[t_?NumericQ] := If[0 <= t <= 72, cmaxd[t], 0] f2[t_] := Sum[f1[t - i], {i, 0, t, 12}] Plot[f2[i], {i, 0, 120}, AxesLabel -> {"hour", "concentration"}]


10

My guess is to be able to have the same internal representations as for linear systems. It is not possible to represent a system using A,B,C,D state space standard matrices without the system being linear. For example, say the ODE was not linear, as in $x''(t)+x^2(t)=1$. Convert to state space. Let $x_1=x,x_2=x'$. Taking derivatives gives $x_1'(t)=x_2,x_2'=...


10

Looks like a little three-species food web model -- a perfect excuse to use my new EcoEvo package. First, install the package (one-time only): PacletInstall["https://github.com/cklausme/EcoEvo/releases/download/v1.0.1/EcoEvo-1.0.1.paclet"] Then load the package and set the model for analysis with SetModel: << EcoEvo` SetModel[{ Pop[x] -> {...


10

It is not 2D problem, but 3D problem. So we actually need some 3D model to describe deformation. But before do this, we can describe the problem in the beam theory. Fortunately, this problem has exact solution - see, for instance, Landau and Lifshitz Theory of Elasticity. Parameters of the problem in the beam theory inert = .1^4/12; L = 3.2; Y = 2.10 10^11; ...


10

I think you guys are using the wrong theory, as far as I understood the code above. Sadly I only have little time, and in this answer I can only give you the theory without code. If I read your code wrong and you are using the equivalent correct theory, then I apologize of course :D. In continuum mechanics of solid bodies, you generally have material points $...


9

You may use NMinimize[] on the results of ParametricNDSolve[] like this: g = 9.81; m = 10; rho = 1.225; Cd = 0.5; A = 0.1; rcd = rho Cd A; vMax = 40; EndTime[theta_] := (2 vMax Sin[theta])/g + 5; sol[Ux_, Uy_, Uz_] := Quiet@ParametricNDSolve[{ m z''[t] == -m g - Tanh[z'[t]] 1/2 rcd (z'[t] - Uz)^2, z[0] == 0, z'[0] == v Cos[theta], m x''...


9

Add the option PlotRange (say PlotRange -> {{0, .006}, {0, 90}}), and use data2 as Epilog: Plot[Evaluate[F[x] /. FindFit[data2, F[x], {k, n}, x]], {x, 0, .006}, PlotRange -> {{0, .006}, {0, 90}}, Epilog -> {Red, PointSize[Large], Point@data2}] Alternatively, use Plot first in Show: Show[Plot[Evaluate[F[x] /. FindFit[data2, F[x], {k, n}, x]],...


8

Pure GammaDistribution does not seem at all like a good fit even visually. You need probably a MixtureDistribution. You could BTW skip NonlinearModelFit and start playing with FindDistributionParameters. But I think you are better of trying out latest WL function FindDistribution. In automated regime it finds almost what you need: dis = FindDistribution[...


8

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


8

A curve that is a multiple of a gamma distribution seems to fit: r0 = Max[data[[All, 1]]] + 0.0001; nlm = NonlinearModelFit[data, r1 E^(-((r0 - x)/r2)) r2^-r3 (r0 - x)^(-1 + r3), {{r1, 0.004}, {r2, 6}, {r3, 1}}, x] Show[ListPlot[data, PlotStyle -> {{Yellow, PointSize[0.02]}}], Plot[nlm[x], {x, 60, 90}, PlotStyle -> {{Thin, Red}}]] area = ...


8

Thanks to @xzczd answer we can reproduce solution with FEM. First we should note that $[A]+[B]+[C]=[A]_{bulk}$ in a case of equal $D_A=D_B=D_C$, therefore we can exclude equation for $[A]$ and resolve bc at $x=0$ as follows ss = Solve[{bulk - cC - cB == Exp[FbyRT (\[CapitalEpsilon][t] - efab)] cB, cB == Exp[FbyRT (\[CapitalEpsilon][t] - efbc)] cC}, {...


7

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


7

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


7

you can use PixelValuePositions Show[image, MapThread[Graphics[{#2, Point@RandomSample[PixelValuePositions[image, #1], 2000]}] &, {{0, 1}, {Red, Blue}}]] of course there are some outlying points and that is because your image has a thin white border surrounding it


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