MathGroup Archive 2007

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

Search the Archive

Can model parameters be global?

When implementing a mathematical model in physics or psychology, for
example, how do other people deal with model parameters in Mathematica?
Would you represent the speed of light as a global variable or a local
variable. For example, would you use

Energy[m_]:=m*c^2  (* c is a global variable *)


Energy[m_,c_]:=m*c^2 (* c is a local variable *)


The first seems neater. But problems arise in psychology, my domain, where
the values of model parameters are unknown and are left as free parameters,
adjusted to best-fit the data.

Both local and global methods work well with optimisation. For example,

{0., {c -> 0.}}


{0., {c -> 0.}}

But the global variable solution does not work well with Manipulate.
For example,

Manipulate[Dynamic[Energy[1]], {c, 0, 1}, LocalizeVariables -> False]

works, but looks a right mess and also results in c taking a value that
needs a Clear[c] before using other functions like NMinimize. On the other
hand the local variable version

Manipulate[Energy[1, c], {c, 0, 1}]

is nice and simple. But the local variable solution results in having to
pass all of the model parameters to the function. This is fine in this
trivial example, but becomes unwieldy when there are ten model parameters
and the model is defined using a set of functions. (A c-like struct could
help, but there does not seem to be a neat way to do this in Mathematica.)

So what do other people do? I'd be really interested to hear.

  • Prev by Date: Re: Projectile motion
  • Next by Date: Re: how to collapse a cell in v.6
  • Previous by thread: Re: Block vs. ReplaceAll
  • Next by thread: Re: Can model parameters be global?