MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Modifying Fit[] using SingularValues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23424] Re: Modifying Fit[] using SingularValues
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 10 May 2000 02:32:11 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <8f55db$49p@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

MakeFunctions[fname_, x_Symbol, flst_] :=
  Module[{arg, lst, patt},
    lst = flst /. x -> arg;
    patt = Pattern  @@ {arg, Blank[]};
    MapIndexed[(fname[First[#2]][patt] := #1) &, lst]]

    

will take a name like qq for your functions, a symbol x for 
the argument and a function list like {1,x,x^2}
It will generate qq[1], qq[2],qq[3] functions

MakeFunctions[qq, x, {1, x, x^2}]

and

?? qq

"Global`qq"

qq[1][arg$5_]:=1
qq[2][arg$5_]:=arg$5
qq[3][arg$5_]:=arg$5^2


Hope that helps
  Jens


> What I want to do and can't figure out, is how to take a list of
> expressions like {1,x,x^2} and use them like I used the explicitly
> defined functions f1, f2, and f3 above.  So then I could define a
> function myFit which would be invoked like Fit, i.e.
> 
> myFit[Transpose[{testx,testy}],{1,x,x^2,Sin[x]},x]
> 
> and yield a1 + a2 x + a3 x^2 + a4 Sin[x], along with chisquared and
> the variance for each parameter.
> 
> Bill Campbell


  • Prev by Date: Starting Mathematica kernal from external programs
  • Next by Date: How to Play Sound from FrontEndTokenExecute
  • Previous by thread: Modifying Fit[] using SingularValues
  • Next by thread: Can FindMinimum solve boundary value problems?