I have the following list of rules:
minru = {"ksp" -> 0.3393, "pl" -> 0.3675, "qtz" -> 0.1628,
"hb" -> 0.0714552, "bi" -> 0.0476368, "sph" -> 0.006268,
"zrc" -> 0.000672, "ilm" -> 0.000168, "ap" -> 0.000348,
"aln" -> 0.000812, "cal" -> 0.002, "fl" -> 0.003}
I want to use this to make a Manipulate
-able list as output. I want to turn the keys (rhs) into a set of variables and use the values (lhs) to define the range and initial parameters for the variables. I'm hoping to get a list of adjustable, normalised values within a manipulate frame with a slider for each input variable.
Here is the kind of thing I'm trying to achieve (minus the programatic variable definition):
Manipulate[
Module[{sum, vars},
sum = x + y + z;
vars = {x/sum, y/sum, z/sum}],
{{x, 0.33}, 0.001, 0.5, Appearance -> "Open"},
{{y, 0.33}, 0.001, 0.5, Appearance -> "Open"},
{{z, 0.33}, 0.001, 0.5, Appearance -> "Open"}]
What I've tried to far:
mantest[propru_] :=
Manipulate[
Module[{manvars, tot},
manvars = ToExpression[propru[[All, 1]]];
tot = Total[manvars];
(#/tot) & /@ manvars
],
Evaluate[Sequence @@
ReplaceList[propru,
KeyValuePattern[{x_ -> y_}] :>
{{ToExpression[x], y}, y - 0.5 * y, y + 0.5 * y}]]
]
mantest[minru]
Alas, Mathematica says "no"...
This question got me some of the way but the variable parameters (from lhs) still aren't working....
Any suggestions on how to do this? Do need to use Hold
somewhere?
mantest[propru_] :=DynamicModule[{manvars=Symbol/@Keys[propru], values=Values@propru },Manipulate[Evaluate@Normalize[manvars ,Total],Evaluate[Sequence@@({{##},(1-.5)#2,(1+.5)#2}&@@@Transpose[{manvars, values}])] ]]; mantest[minru]
? ` $\endgroup$Normalize[vars, Totla]
or do you want to be able to use them separately e.g.ksp + aln
. $\endgroup$var_i / sum(var)
. Does this make sense? $\endgroup$