Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Smooth the data in a table, Why this cannot work?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62535] Re: [mg62513] Smooth the data in a table, Why this cannot work?
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 27 Nov 2005 02:40:22 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

data=ToExpression[Table[#<>ToString[n]&/@{"x","y"},{n,12}]];

This is what you appear to be trying

For[i=4,i<9,data[[i,2]]=(1/35)
      (-3(data[[i-3,2]]+data[[i+3,2]])+
          12(data[[i-2,2]]+data[[i+2,2]])+
          17(data[[i-1,2]]+data[[i+1,2]]));
  i++]

However, it may not be what you want.  Note, for instance, that y4 never 
appears.

data//Simplify

{{x1, y1}, {x2, y2}, {x3, y3}, {x4, (1/35)*(17*(y3 + y5) + 12*(y2 + y6) - 3*(y1 + 
y7))}, 
  {x5, (-51*y1 + 99*y2 + 709*y3 + 289*y5 + 799*y6 + 369*y7 - 105*y8)/
1225}, 
  {x6, (-2127*y1 + 6723*y2 + 15518*y3 + 12053*y5 + 18623*y6 + 
25838*y7 + 12915*y8 - 3675*y9)/
    42875}, {x7, (-46554*y1 - 128625*y10 + 111771*y2 + 499111*y3 + 
263806*y5 + 608071*y6 + 
     605251*y7 + 904330*y8 + 452025*y9)/1500625}, 
  {x8, (-1497333*y1 + 15820875*y10 - 4501875*y11 + 4359942*y2 + 
12396872*y3 + 8484887*y5 + 
     15222542*y6 + 19785152*y7 + 21183785*y8 + 31651550*y9)/
52521875}, {x9, y9}, {x10, y10}, 
  {x11, y11}, {x12, y12}}

Here is an alternate approach

Clear[smoothedData];

smoothedData[data_List, weights_?VectorQ]:=
    Module[{y=data[[All,2]]},
      Thread[{
          data[[All,1]],
          Join[
            Take[y,Floor[Length[weights]/2]],
            ListCorrelate[weights,y]/Total[weights],
            Take[y,-Floor[Length[weights]/2]]]}]];

data=ToExpression[Table[#<>ToString[n]&/@{"x","y"},{n,12}]];

weights={1,3,9,27,9,3,1};

smoothedData[data,weights]

{{x1, y1}, {x2, y2}, {x3, y3}, {x4, (1/53)*(y1 + 3*y2 + 9*y3 + 27*y4 + 9*y5 + 
3*y6 + y7)}, 
  {x5, (1/53)*(y2 + 3*y3 + 9*y4 + 27*y5 + 9*y6 + 3*y7 + y8)}, 
  {x6, (1/53)*(y3 + 3*y4 + 9*y5 + 27*y6 + 9*y7 + 3*y8 + y9)}, 
  {x7, (1/53)*(y10 + y4 + 3*y5 + 9*y6 + 27*y7 + 9*y8 + 3*y9)}, 
  {x8, (1/53)*(3*y10 + y11 + y5 + 3*y6 + 9*y7 + 27*y8 + 9*y9)}, 
  {x9, (1/53)*(9*y10 + 3*y11 + y12 + y6 + 3*y7 + 9*y8 + 27*y9)}, {x10, 
y10}, {x11, y11}, 
  {x12, y12}}

data={{280.00,.000},
{282.00,.002},
{284.00,.002},
{286.00,.000},
{288.00,.000},
{290.00,.002},
{292.00,.003},
{294.00,.003},
{296.00,.003},
{298.00,.011},
{300.00,.031},
{302.00,.076}};

sd=smoothedData[data,weights];

ListPlot[sd,
    PlotJoined->True,
    Epilog->{
        AbsolutePointSize[8],Blue,Point/@sd,
        AbsolutePointSize[5],Red,Point/@data},
    PlotRange->All,ImageSize->432];


Bob Hanlon

> 
> From: "simon yang" <yanshanguke at 163.com>
To: mathgroup at smc.vnet.net
> Date: 2005/11/26 Sat AM 02:47:14 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg62535] [mg62513] Smooth the data in a table, Why this cannot work?
> 
> Hello, every one. I meet a problem when I smooth the data in a table:
> 280.00,.000
> 282.00,.002
> 284.00,.002
> 286.00,.000
> 288.00,.000
> 290.00,.002
> 292.00,.003
> 294.00,.003
> 296.00,.003
> 298.00,.011
> 300.00,.031
> 302.00,.076
> The method I used is:
> For[i=3,i<=9,data[[1,i]][[2]] = (1/35)( -3(data[[1,i-3]][[2]]
> +data[[1,i+3]][[2]]) +12(data[[1,i-2]][[2]] +data[[1,i+2]][[2]])
> +17(data[[1,i-1][[2]] +data[[1,i+1]][[2]]));  i++]
> it doen't work
> 
> the function Replace[] also don't work
> \!\(For[i = 3,
>     i = \ 9, Replace[
>       datatemp, \(data[\([1, i]\)]\)[\([2]\)] -> \(1\/35\) \((\(-3\) \
> \((\(data[\([1, i - 2]\)]\)[\([2]\)] + \(data[\([1, i +
> 2]\)]\)[\([2]\)])\) +
>             12 \((\(data[\([1, i -
>                 1]\)]\)[\([2]\)] + \(data[\([1, i + 1]\)]\)[\([2]\)])\)
> +
>                         17 \( data[\([1, i]\)]\)[\([2]\)])\)];
> \(i++\)]\)
> 
> Then what should I do ? 
> Thanks.
> 
> 


  • Prev by Date: Re: Smooth the data in a table, Why this cannot work?
  • Next by Date: Re: Re: Re: Types in Mathematica
  • Previous by thread: Re: Smooth the data in a table, Why this cannot work?
  • Next by thread: webMathematica - does it need the Xvnc password?