MathGroup Archive 2010

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

Search the Archive

Re: Binning a dependent variable


   tempBinWidth_?NumericQ}] :=
    values = data[[All, 2]],
    tbw = Min[tempBinWidth, tempMax - tempMin]},
   filteredData = Select[data,
     tempMin <= # [[1]] <= tempMax &];
   If[filteredData == {}, {},
    If[# == {}, {}, {Mean[#[[All, 1]]],
        Mean[#[[All, 2]]]}] & /@
       {tempMin, tempMax, tbw},
       {Min[values], Max[values],
        Max[values] - Min[values]}],
      1]]] /; tempMin < tempMax 

data = Table[
   {RandomReal[{-100, 1000}], RandomReal[]},

avgByBin[data, {0, 500, 100}]

Bob Hanlon

---- northern_flicker <max_kip at> wrote: 

Dear Forum

I have data with x and y values, i.e., temperature and a variable dependent on the temperature, e.g., 

{{30, 0.0019}, {31, 0.0024}, {32, 0.0026}...{998,0.000005},{999,0.000004},{1000,0.000003}}, with, for example, 3000 measurements in total.

I would like to:

1) Bin the temperature data (x) into bins of any desired width, plus
2) specify the temperature range over which to bin the data and 
3) bin the corresponding dependent variable (y), so that I can calculate the corresponding mean y for the temperature bin, ultimately resulting in: 


where x is now the mean temperature and y is the mean dependent variable for that temperature bin.

I tried to manipulate BinLists and BinCounts to solve this problem, but ran into difficulties.

Any help would be much appreciated

  • Prev by Date: Re: "Abort Evaluation" does not work
  • Next by Date: Re: There must be a better way.
  • Previous by thread: Binning a dependent variable
  • Next by thread: Re: Binning a dependent variable