Mathemmatical notation for the summation of the sets based on some other sets values.

68 Views Asked by At

Here are the example set values.:

X = [x1,x2,x3,x4,x5]
P = [x1,x1,x2,x3,x4,x1,x2,x5,x3,x2]

Here x1,x2,x3,x4,x5 are some numeric values.

What I am trying to do is:

Adding the respective values and creating a set according to the values in X

C = [3,3,2,1,1]

where,

C1, i.e. 3, is the sum of all the values of P which are equal to X[1]
C2, i.e. 2, is the sum of all the values of P which are equal to X[2]
C3, i.e. 1, is the sum of all the values of P which are equal to X[3]
C4, i.e. 1, is the sum of all the values of P which are equal to X[4]
C5, i.e. 3, is the sum of all the values of P which are equal to X[5]

I thought of something like the following, but it seems like it has flaws:
$$\sum_{k=1}^n P(x_k \in X) + C(x)$$

Please suggest me what could be the best possible output notation for the condition I have mentioned in my description.

2

There are 2 best solutions below

2
On

This might be a job for the Kronecker delta function. If $x = y$, then $\delta_y^x = 1$, but if $x \neq y$, then $\delta_y^x = 0$.

Then, if $\mathcal L_P$ is how many elements $P$ has and $\mathcal L_X$ is how many elements $X$ has, then, given $0 < n \leq \mathcal L_X$, we have $$C_n = \sum_{k = 1}^{\mathcal L_P} \delta_{X_n}^{P_k}.$$ Note bene that $n$ is a constant for the scope of the summation, but $k$ iterates and is a subscript for $P$, not $X$.

Others will have better ideas, but my idea is probably the best you can hope for on a Saturday afternoon.

0
On

Mathematically, $P$ is not a set since it can contain the same element several times. Instead it can be described as a function $P : \{ 1, \ldots, N_P \} \to X.$ Then $C$ is a function, $C : \{ 1, \ldots, N_X \} \to \{ 1, \ldots, N_P \}.$ We also have an enumeration $X_n$ of the elements in $X.$

Now $C_n$ should give the number of times that $x_n$ is "contained" in $P,$ i.e. the number of values in the domain of $P$ that map to $x_n$, we can write $$C_n = |P^{-1}(\{ X_n \})|.$$ Here $|S|$ denotes the number of elements in the set $S.$