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


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

Re: Summation of imported data

From Peter <petsie@dordos.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Summation of imported data
Date 2011-05-15 11:06 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iqoc39$mal$1@smc.vnet.net> (permalink)
References <iqla6j$a10$1@smc.vnet.net>

Show all headers | View raw


Am 14.05.2011 09:15, schrieb Thomas:
> I know what I want to do but I dont know how to implement it onto Mathematica.
>
> What I am trying to do is create an objective function that I can get a good fit to my data points.
>
> The function I want to minimize is:
>   Cstardiff[t_, De_, dprime_] := 1 - 2 dprime Sqrt[t De/Pi]
>
> I have two imported data sets, time1 and con1 that are in lists
>
> So I want to do a summation from i=1 to 63, (because there is 63 terms for each imported data set), and my summation function would be:
> (con1(i) - Cstardiff[time1(i), De_, 1])^2
>
> If anyone can help me with this that would greatly appreciated!
>
Hi Thomas,

I'll construct example data:

In[6]:= time=Range[63]*2Pi/63.;
con1=1-2*1.01*Sqrt[time * 3.21/Pi]+RandomReal[{-.01,.01},63];
In[3]:= ListPlot[Transpose@{time,con1}]
(* omitted *)

In[8]:= Cstardiff[t_,De_,dprime_]:=1-2 dprime Sqrt[t De/Pi]

as most numeric functions thread over lists, there is no need for a loop:

In[16]:= errsum=Total[(con1-Cstardiff[time,De,1])^2]//ExpandAll
Out[16]= 838.347 -926.534 Sqrt[De]+256. De

now you can find the best De:

In[17]:= Minimize[{errsum,De>0},De]
Out[17]= {0.00205585,{De->3.27478}}

and your function becomes:

In[18]:= Cstardiff[t,De,1]/.%[[2]]
Out[18]= 1-2.04196 Sqrt[t]

with built-in functions:

In[19]:= NonlinearModelFit[Transpose@{time,con1},
    Cstardiff[t,De,1],{De},t]//Normal
Out[19]= 1-2.04196 Sqrt[t]

hth,
Peter

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


Thread

Summation of imported data Thomas <imadorkous@gmail.com> - 2011-05-14 07:15 +0000
  Re: Summation of imported data Peter <petsie@dordos.net> - 2011-05-15 11:06 +0000

csiph-web