# Tag Info

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

1

I don't think you can get a solution by just throwing the problem at Solve. If you make a minor change in the argument you give to Solve (substituting 95/100 for 0get.95), you will get a message you may find more meaningful. Solve[ CDF[ChiSquareDistribution[n - 1], (n - 1)/k1] - CDF[ChiSquareDistribution[n - 1], (n - 1)/k2] == 95/100 && ...

1

I think GridLineData should be optimized by adding a condition as below: Classify the data that has been sorted by using this condition that the numerical difference is small (i.e., two data is very close to) (classification interval is set to δ), In each class of data, the minimum number of as a representative of the group(the last group must take ...

1

How about this? Grid[Prepend[ Flatten[Table[{a, b, Reverse@NMinimize[{a x + b y, 0.2 x + 0.1 y >= 14, 0.25 x + 0.6 y >= 30, 0.1 x + 0.15 y >= 10, x >= 0, y >= 0}, {x, y}]}, {a, 0, 3, 1}, {b, 0, 3, 1}] /. {ap_, bp_, {{x -> xp_, y -> yp_}, axbyp_}} :> {ap, bp, xp, yp, axbyp}, 1], {"a", "b", "x", ...

3

I'm not sure exactly what you want, but in an effort to demonstrate some possibilities: Join @@ Table[{{a, b}, NMinimize[{a x + b y, 0.2 x + 0.1 y >= 14, 0.25 x + 0.6 y >= 30, 0.1 x + 0.15 y >= 10, x >= 0, y >= 0}, {x, y}][[2]]}, {a, 0, 3, 1}, {b, 0, 3, 1}] // Column Or: Join @@ Table[{{HoldForm[a] -> a, HoldForm[b] -> ...

Top 50 recent answers are included