Tag Info

New answers tagged

9

Two approaches: Finding maxima (1) of an InterpolatingFunction and (2) via NDSolve. InterpolatingFunction To find the extrema of an InterpolatingFunction, one should start with the data contained in the function. Let's start with the function itself; ifn = theta /. sol Then ifn["Grid"] and ifn["VaiuesOnGrid"] contain the abscissas (t) and ordinates ...


12

As described e.g. in the tutorial Numerical Nonlinear Global Optimization there are different optimization methods available. For your problem "SimulatedAnnealing" seems to work: NMaximize[{Theta[t], 0 <= t <= tmax}, t, Method -> "SimulatedAnnealing"] {0.687071, {t -> 48.2449}} "DifferentialEvolution" will work, if the population is of ...


4

Either of the following, taken from the comments, will work. kguler's answer. NMinimize[{a + 1, {Or @@ (a == #& /@ {-1, 0, 2}) && a > 0}}, a] belisarius' answer. NMinimize[{a + 1, Times @@ ((a - #)& @ {-1, 0, 2}) == 0}, a]


0

In principle 63 variable is not a problem. Lets define them var = Table[ToExpression["x" <> ToString[i]], {i, 64}]; and a Quadratic function Q = var.var; This defines the function fun = Compile[Sequence@Map[{{#, _Real}} &, var] // Evaluate, Q, CompilationOptions -> {"InlineExternalDefinitions" -> True}]; and the minimization ...


4

Update What if we use instead of Sin an expression like a+b? I'll try a simple example, namely minimizing $(a + 3)^2 + (b - 3)^2$. Making use of CompilationOptions, I'll define a function with two variables, then nest that inside another compiled function prior to minimization. Needs["CompiledFunctionTools`"] myfunction = Compile[{{a}, {b}}, (a + ...


3

{min, argmin} = NMinimize[Total@diff1, {a, b}]; (* {0., {a -> 1., b -> 0.159155}} -- as expected since N[1/(2*Pi)] is 0.159155 *) {ahat, bhat} = argmin[[All,2]]; (* {1., 0.159155} *) pred = Table[ahat Sin[i bhat], {i, 1, 20}]; ListPlot[{data1, pred}, Joined -> {False, True}]


1

As defined, eislminx2 returns a list rather than a value. I modified its definition to use First (only?) value. I rationalized your equations so that they do not limit the precision of the calculations. In addition to specifying a value for epsilon, h needs a value. Do you know any constraints on values of n1 or n2 (region of interest)? eislexpl[epsilon_, ...


1

dist = MixtureDistribution[{0.2, 1 - 0.2}, {LogNormalDistribution[-2, 0.3], LogNormalDistribution[1.1, 0.3]}]; SeedRandom[1]; dat2 = RandomVariate[dist, 100]; estDist = EstimatedDistribution[dat2, MixtureDistribution[{p, 1 - p}, {LogNormalDistribution[\[Mu]1, \[Sigma]], LogNormalDistribution[\[Mu]2, \[Sigma]]}]] ...


2

First, note that since $ds_x,qp_x,pp_{xy}$ are constants, the expression $z$ can be simplified greatly: $$z=\{ds_1[(cp_{11}qp_1pp_{11}+...+(cp_{m1}qp_mpp_{m1})]+...+ds_n[(cp_{1n}qp_1pp_{1n}+...+(cp_{mn}qp_mpp_{mn})]\} \\ =\sum_{i,j}k_{ij}cp_{ij} \\ =\mathbf{k}\cdot\mathbf{c}$$ where $$\mathbf{c}=\text{vec}(cp) \\ \mathbf{k}=\text{vec}(k)$$ where ...



Top 50 recent answers are included