# Thread: Math notation break set into n length groups

1. ## Math notation break set into n length groups

I have a vector of length 26 and want to split it into groups of length 5. I can write it in code but what's the math notation for breaking a set up into n length groups keeping the elements consecutively ordered?

Using what Bryan Goodrich wrote here: http://www.talkstats.com/showthread....l=1#post178934

I know I have a set of length 26 which I could write as:

How can I say split d in to groups of 5? It seems d/5 isn't really what I'm doing so I don't think that's the right notation (especially since the sub groups need to be consecutive).

Code:
``````w <- LETTERS
groups <- rep(1:(ceiling(length(w)/5)), each = ceiling(length(w)/(ceiling(length(w)/5))))#[1:length(w)]
split(w, groups)``````
Code:
``````> LETTERS
[1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S"
[20] "T" "U" "V" "W" "X" "Y" "Z"``````
Code:
``````> split(w, groups)
\$`1`
[1] "A" "B" "C" "D" "E"

\$`2`
[1] "F" "G" "H" "I" "J"

\$`3`
[1] "K" "L" "M" "N" "O"

\$`4`
[1] "P" "Q" "R" "S" "T"

\$`5`
[1] "U" "V" "W" "X" "Y"

\$`6`
[1] "Z"``````

2. ## Re: Math notation break set into n length groups

Functionally, I'd make this function

Code:
``````n_groups <- function(x, n)
{
N <- length(x)
groups <- rep(1:ceiling(N/n), each = n, length.out = N)
split(x, groups)
}``````
The notation I would use might be something like you have a domain defined as a sequence {a}_n = {a_1, a_2, ..., a_n}. From this you're partitioning (see calculus/real analysis notation for partitioning with regards integration) this domain into sub-sequences {b}_m. Here the relationship of n and m correspond to my code as n := N and m := ceiling(N/n), but we're still missing which group it is. Maybe a j parameter like {b_j}_m, where b_1 is the first group partitioned by m {A, B, C, D, E), and b_6 is the last group {Z} with m=1.

https://en.wikipedia.org/wiki/Partition_of_an_interval <-- Helpful, and an interval is just a continuous version of a sequence

3. ## The Following User Says Thank You to bryangoodrich For This Useful Post:

trinker (04-12-2016)

4. ## Re: Math notation break set into n length groups

Well 26 isn't divisible by 5, so splitting d into groups of length 5 is not possible... (note that this is not exactly what your code does, since one of the resulting groups has length 1)

5. ## Re: Math notation break set into n length groups

Another way to think of the notation is how Wolfram denotes sequences

http://mathworld.wolfram.com/Subsequence.html

Arbitrarily, you have some sequence (vector) {a} = a_n for n in 1...N. What you want is to define subsequences {b} = b_k for k in sub intervals of 1...n which we can denote b_k = a_(n_k) where the (n_k) is picking out the elements in the 1...n interval that belong to this {b}. Thus, my previous point, we're defining multiple {b} that we might want to flag with some index j, maybe {b^j}. Thus, we would have

6. ## The Following User Says Thank You to bryangoodrich For This Useful Post:

trinker (04-12-2016)

7. ## Re: Math notation break set into n length groups

I'm not sure what this is for, but if the point is just to describe what some algorithm is doing in a more general/abstract way than giving the actual syntax, then it might make more sense to use pseudocode rather than more formal math notation.

But a mathy way to say this might be: we define a sequence of subsequences such that . And you could refer to the individual elements of the using .

8. ## The Following User Says Thank You to Jake For This Useful Post:

trinker (04-12-2016)

 Tweet

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts