Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Can somebody please explain me the following:

If I try to split data every increase in 0.5:

list = Range[1.2, 3.2, 0.15]

{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}

I would like to get the following:

{{1.2, 1.35, 1.5, 1.65}, { 1.8, 1.95, 2.1}, {2.25, 2.4, 2.55, 2.7}, {2.85,3., 3.15}

If I use the example given I here:

Splitting a list using SplitBy, by comparing adjacent elementsSplitting a list using SplitBy, by comparing adjacent elements

I can split either not at all

splittedlist = Split[list, (#1 < ( #2 - 0.1)) &]

 {{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}}

or I can split each of them

splittedlist = Split[list, (#1 < ( #2 - 0.5)) &]

{{1.2}, {1.35}, {1.5}, {1.65}, {1.8}, {1.95}, {2.1}, {2.25}, {2.4}, {2.55}, {2.7}, {2.85}, {3.}, {3.15}}

I found this package,

http : // www.theophys.kth.se/~phl/Mathematica/

which uses exactly this method (on 2D data, but still), why does it work in their method? Obviously, I am missing something.

I found this way of doing it,

Calculate mean of values in binsCalculate mean of values in bins

but is this really the simplest way to split into intervals? I could of course write a loop, but I tried to not use a loop.

Can somebody please explain me the following:

If I try to split data every increase in 0.5:

list = Range[1.2, 3.2, 0.15]

{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}

I would like to get the following:

{{1.2, 1.35, 1.5, 1.65}, { 1.8, 1.95, 2.1}, {2.25, 2.4, 2.55, 2.7}, {2.85,3., 3.15}

If I use the example given I here:

Splitting a list using SplitBy, by comparing adjacent elements

I can split either not at all

splittedlist = Split[list, (#1 < ( #2 - 0.1)) &]

 {{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}}

or I can split each of them

splittedlist = Split[list, (#1 < ( #2 - 0.5)) &]

{{1.2}, {1.35}, {1.5}, {1.65}, {1.8}, {1.95}, {2.1}, {2.25}, {2.4}, {2.55}, {2.7}, {2.85}, {3.}, {3.15}}

I found this package,

http : // www.theophys.kth.se/~phl/Mathematica/

which uses exactly this method (on 2D data, but still), why does it work in their method? Obviously, I am missing something.

I found this way of doing it,

Calculate mean of values in bins

but is this really the simplest way to split into intervals? I could of course write a loop, but I tried to not use a loop.

Can somebody please explain me the following:

If I try to split data every increase in 0.5:

list = Range[1.2, 3.2, 0.15]

{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}

I would like to get the following:

{{1.2, 1.35, 1.5, 1.65}, { 1.8, 1.95, 2.1}, {2.25, 2.4, 2.55, 2.7}, {2.85,3., 3.15}

If I use the example given I here:

Splitting a list using SplitBy, by comparing adjacent elements

I can split either not at all

splittedlist = Split[list, (#1 < ( #2 - 0.1)) &]

 {{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}}

or I can split each of them

splittedlist = Split[list, (#1 < ( #2 - 0.5)) &]

{{1.2}, {1.35}, {1.5}, {1.65}, {1.8}, {1.95}, {2.1}, {2.25}, {2.4}, {2.55}, {2.7}, {2.85}, {3.}, {3.15}}

I found this package,

http : // www.theophys.kth.se/~phl/Mathematica/

which uses exactly this method (on 2D data, but still), why does it work in their method? Obviously, I am missing something.

I found this way of doing it,

Calculate mean of values in bins

but is this really the simplest way to split into intervals? I could of course write a loop, but I tried to not use a loop.

Tweeted twitter.com/#!/StackMma/status/461107530434084864
edited title
Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

Splitting Breaking a sorted list into sublists equal intervalbins of a specified size

Source Link

Splitting a list into sublists equal interval

Can somebody please explain me the following:

If I try to split data every increase in 0.5:

list = Range[1.2, 3.2, 0.15]

{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}

I would like to get the following:

{{1.2, 1.35, 1.5, 1.65}, { 1.8, 1.95, 2.1}, {2.25, 2.4, 2.55, 2.7}, {2.85,3., 3.15}

If I use the example given I here:

Splitting a list using SplitBy, by comparing adjacent elements

I can split either not at all

splittedlist = Split[list, (#1 < ( #2 - 0.1)) &]

 {{1.2, 1.35, 1.5, 1.65, 1.8, 1.95, 2.1, 2.25, 2.4, 2.55, 2.7, 2.85, 3., 3.15}}

or I can split each of them

splittedlist = Split[list, (#1 < ( #2 - 0.5)) &]

{{1.2}, {1.35}, {1.5}, {1.65}, {1.8}, {1.95}, {2.1}, {2.25}, {2.4}, {2.55}, {2.7}, {2.85}, {3.}, {3.15}}

I found this package,

http : // www.theophys.kth.se/~phl/Mathematica/

which uses exactly this method (on 2D data, but still), why does it work in their method? Obviously, I am missing something.

I found this way of doing it,

Calculate mean of values in bins

but is this really the simplest way to split into intervals? I could of course write a loop, but I tried to not use a loop.