| Author |
Comment/Response |
Amanda
|
05/15/12 7:14pm
Hi, I don't use mathematica much, so maybe I am doing something really silly. I am trying to reassign the last element of a set with another element. Here is the relevant portion of my code:
nelder[Set_, f_, tau_, kmax_, n_, mu_, x_] :=
Module[{S = SortBy[Set, f], fflag, gflag, fcount, xbar, xmax, varr,
fr, vare, fe, varoc, foc, varic, fic, i},
.
.
.
While[f[S[[n + 1]]] - f[S[[1]]] > tau && fcount < kmax,
xbar := Total[S]/n;
xmax := S[[n + 1]];
varr := x[mu[[1]], xmax, xbar];
Print[S];
fr := f[varr];
fcount++;
If[ fcount == kmax, Break];
If[f[S[[1]]] <= fr && fr < f[S[[n + 1]]],
Print["varr ", varr];
S[[n + 1]] = varr; (* THIS ASSIGNMENT IS NOT WORKING! *)
Print["Sn+1 ", S[[n + 1]]];
gflag := 1 ];
.
.
.
AND it prints out
{{1,1},{1,2},{-1,-1},{3,4}}
varr {-(1/3),0}
Sn+1 {3,4}
Could someone please help explain to me why this re-assignment is not working as I want it to? Thanks!
URL: , |
|