# Change domain on series - Counting aplitudes

If I have a function

$$f(t) = y$$

where $t$ & $y$ are positive Integers

for $t = \{1,2,3,4,5,6,7,8\} \to y = \{1,1,1,2,1,2,3,1\}$

How can I create a function $g(y)$ such that it counts the number of times a value of $y$ occurs. For instance if we used the above data $g(y)$ would be the following:

$g(y) = \{5, 2, 1, 0\}$ for the $y$ values $\{1,2,3,4\}$

Once I have this I need to represent this as a function $k(t) = \max R$

$$R = y * g(y) + y * g(y+1) + y * g(y+2)...+ y * g(y+n)$$

for all values $g(y+n) > 0$.

Please can someone help me represent $k(t)$ more mathematically. Would something like the Discrete time Fourier Transform help with $f(t) \Longrightarrow g(y)$

Thanks a mill

-
Do you need that for a program? If it's just a mathematical definition you need for $g$, a definition in words is perfectly fine. – Raskolnikov Aug 27 '12 at 8:28

## 1 Answer

One way you could do this is with the Kronecker delta function, then you can define $g$ as follows

$$g(y)=\sum_{k\in t} \delta_{y,f(k)}$$

with $t=\{1,2,3,\ldots,8\}$ or whatever your domain for $f$ is.

Taking your example, suppose you want to compute $g(1)$, then you add up all the $\delta_{1,f(k)}$ for all $k \in t$. But since $f(k)=1$ only 5 times, the $\delta_{1,f(k)}$ will be equal to $1$ only 5 times and all other times it will be $0$. Therefore the sum is $5$, which is indeed what we want.

-
Thanks for this, I ended up creating my own version of this Kronecker delta function :) (((x-y)/(y-x))+1)/2 This gives me 1 when x=y and 0 for anything else – Manatok Aug 27 '12 at 9:40