Re: Using "Fit"
- To: mathgroup at smc.vnet.net
- Subject: [mg16175] Re: Using "Fit"
- From: dreiss at !SPAMscientificarts.com (David Reiss)
- Date: Tue, 2 Mar 1999 01:13:18 -0500
- Organization: EarthLink Network, Inc.
- References: <7b89mg$4mb@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <7b89mg$4mb at smc.vnet.net>, "Philip M. Howe" <pmhowe at lanl.gov> wrote:
> Hi,
>
> I'm trying to analyze some datasets in a moderately efficient way, and am
> having trouble. Your suggestions will be appreciated.
>
> Suppose that I have a dataset, and I want to fit a function through a
> number of points, where I vary that number systematically, by taking just
> two {x,y} points, then three points, then four, etc. So, if "data" is my
> dataset, I can form new datasets by doing
>
> Take[data,2], Take[data,3], etc. I can then do a fit to each dataset.
>
> Fit[Take[data,2], {1,x},x];
> Fit[Take[data,3], {1,x},x];
> Fit[Take[data,4], {1,x},x]; etc.
>
> But this is slow for large datasets. I can form a table of datasets.
>
> Table[Take[data,n],{n,2,100}];
>
> Now I'd like to apply Fit to each of the lists in the table, and I can't
> figure out the syntax. Or, perhaps there is a better approach.
>
> Thanks in advance for your help.
>
> Phil
If you define
dataTable= Table[Take[data,n],{n,2,100}];
Then using a pure function and Map
Fit[#, {1,x},x]&/@dataTable
will return a list of the corresponding fits.
This should be faster than using something
such as a Do loop.
--
----------------------------------------
Scientific Arts:
Creative Services and Consultation
for the Applied and Pure Sciences
http://www.scientificarts.com
David Reiss
Email: dreiss at !SPAMscientificarts.com
----------------------------------------
Remove the !SPAM to send email