MathGroup Archive 2003

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

Search the Archive

Re: Data preparation and statistics question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41825] Re: [mg41741] Data preparation and statistics question
  • From: Omega Consulting <info at omegaconsultinggroup.com>
  • Date: Fri, 6 Jun 2003 09:50:57 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

At 06:13 AM 6/3/2003, Moranresearch at aol.com wrote:
>I have a set of data l1={xj,yj,zj} where {j,1,n}
>I would like to group the data into a uniform "grid" comprised of "cells".
>The dimension of a cell would be x_increment by y_increment.
>The center of the cell would be (x + x_increment/2,y + y_increment/2}
>The z value would be the Mean of all z values falling within that cell.
>Once I have this  "conditioned" data I wish to do a multiple regression of
>mean z of cells against x,y values of the center of the cells. Thank you.

An example

l1 = Table[Random[], {100}, {3}];

There's a Statistics function, BinLists, which is appropriate for sorting 
the data.

<< Statistics`

regions = BinLists[l1, {0, 1, .2}, {0, 1, .2}, {0, 1}];

So all the data where 0<x<.2 and 0<y<.2 is in the "upper-left" of regions.

regions[[1, 1]]

{{{0.0898259, 0.0648057, 0.563821}, {0.010711, 0.121522, 0.7502}}}

Now we need a function to find the average z value in each region.

AverageZ[region_] :=
   Module[{pts, zs},
     pts = First[region];
     zs = Map[Last, pts];
     Mean[zs]
     ]

And we map it onto each region to get a matrix of z values.

zvalues = Map[AverageZ, regions, {2}]

The x and y values can be generated with a Table.

xyvalues = Table[{x, y}, {x, .1, .9, .2}, {y, .1, .9, .2}]

And paired with the z values.

avgdata = Flatten[MapThread[Append, {xyvalues, zvalues}, 2], 1]

Then you can do your statistical operations on the new dataset.

--------------------------------------------------------------
Omega Consulting
"The final answer to your Mathematica needs"
http://omegaconsultinggroup.com


  • Prev by Date: Re: Boolean type-checking
  • Next by Date: Re: For[] command in Show[] function
  • Previous by thread: Re: Data preparation and statistics question
  • Next by thread: Coverting 3D graphics to 2D raster WITHIN Mathematica