Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5835

Re: Creating Objects

From Armand Tamzarian <mike.honeychurch@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Creating Objects
Date 2011-10-24 09:17 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j83af4$k55$1@smc.vnet.net> (permalink)
References <j80qhd$afd$1@smc.vnet.net>

Show all headers | View raw


On Oct 23, 9:33 pm, Gabriel Landi <gtla...@gmail.com> wrote:
> Dear MathGroup (and perhaps some Wolfram employees),
>
> Does anyone know how to create Objects in Mathematica, such as those produced by LinearModelFit or NDSolve`ProcessEquations?
> For instance, let data be a set of statistical data. Then data["Mean"] would give me the mean, data["Values"] would return me the original values, etc.
>
> Here is an example from LinearModelFit:
>
>         data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}};
>         lm = LinearModelFit[data, x, x];
>         Save["Model.txt",lm];
>
> The saved output is
>
> lm = FittedModel[{"Linear", {0.18644067796610198, 0.6949152542372881},
>       {{x}, {1, x}}, {0, 0}}, {{1., 1., 1., 1.}}, {{0, 1}, {1, 0}, {3, 2},
>       {5, 4}}, {{1., 0.}, {1., 1.}, {1., 3.}, {1., 5.}},
>      Function[Null, Internal`LocalizedBlock[{x}, #1], {HoldAll}]]
>
> Which has, basically, only the data and the fitted parameters. Nonetheless, by doing lm["FitResiduals"] it computes the residuals for me.
>
> In my impression, this is as close as one can get to object-oriented programming in Mathematica, and would be a quite useful feature to use.
> I haven't found any documentation on this. Anyone knowns?
>
> Sincerely,
>
> Gabriel Landi


Darren Glosemeyer provided some info on how to do this

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/96759ba9dbce4c/0827f0d03f5abbd9

Might be useful if this was part of a HowTo in the documentation.

Mike

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Creating Objects Gabriel Landi <gtlandi@gmail.com> - 2011-10-23 10:33 +0000
  Re: Creating Objects Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-10-24 09:17 +0000
  Re: Creating Objects "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-24 09:17 +0000
  Re: Creating Objects Gabriel Landi <gtlandi@gmail.com> - 2011-10-25 10:25 +0000
  Re: Creating Objects A Retey <awnl@gmx-topmail.de> - 2011-10-25 10:24 +0000

csiph-web