This code is longer than David's, but way more modern and fashionable, as it uses LaTeX3 functions.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\chisum}{m} % a homage to John Wayne
{
\aentropy_chisum:n { #1 }
}
\cs_new_protected:Npn \aentropy_chisum:n #1
{
\seq_clear:N \l_aentropy_chisum_seq
\clist_map_inline:nn { #1 }
{
\aentropy_add_summand:n { ##1 }
}
\seq_use:Nn \l_aentropy_chisum_seq { \oplus }
}
\cs_new:Npn \aentropy_add_summand:n #1
{
\__aentropy_add_summand:w #1 \q_stop
}
\cs_new:Npn \__aentropy_add_summand:w #1 , #2 \q_stop
{
\int_compare:nTF { #1 = 1 }
{% if the number of summands is 1, we don't show it
\seq_put_right:Nn \l_aentropy_chisum_seq { \chi\c_math_subscript_token{#2} }
}
{
\seq_put_right:Nn \l_aentropy_chisum_seq { #1\chi\c_math_subscript_token{#2} }
}
}
\ExplSyntaxOff
\begin{document}
$\chisum{{1,0},{2,5},{3,0},{4,1},{5,0},{6,0},{7,2}}$
\end{document}

The idea is just the same: we process the comma separated list and split each item into two components (coefficient and index); we store the built summand in a sequence and then deliver it separating its items with \oplus
.
In order to comply with the second specification, some adaptations must be made.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\chisum}{m} % a homage to John Wayne
{
\aentropy_chisum:n { #1 }
}
\seq_new:N \l_aentropy_chisum_seq
\int_new:N \l_aentropy_chisum_index_int
\cs_new_protected:Npn \aentropy_chisum:n #1
{
\seq_clear:N \l_aentropy_chisum_seq
\int_zero:N \l_aentropy_chisum_index_int
\clist_map_inline:nn { #1 }
{
\int_incr:N \l_aentropy_chisum_index_int
\aentropy_add_summand:n { ##1 }
}
\seq_use:Nn \l_aentropy_chisum_seq { \oplus }
}
\cs_new:Npn \aentropy_add_summand:n #1
{
\int_compare:nF { #1 = 0 }
{
\seq_put_right:Nx \l_aentropy_chisum_seq
{
\int_compare:nF { #1 = 1 } { #1 }
\exp_not:n { \chi }
\c_math_subscript_token
{ \int_to_arabic:n { \l_aentropy_chisum_index_int } }
}
}
}
\ExplSyntaxOff
\begin{document}
$\chisum{5,2,7,8,2,0,0,1,3}$
\end{document}
Note that \exp_not:n { \chi }
is not really necessary, because \chi
is not expandable; but you might want to change the symbol and so it's better to be safe than sorry.
Zero terms are omitted, one terms are printed without the coefficient 1.

With a different definition of \aentropy_add_summand:n
you can also use symbolic coefficients. Each item will be compared to the string 0
and, in this case, no summand will be added; otherwise, the item is compared to 1
and, in this case, no coefficient is added.
\cs_new:Npn \aentropy_add_summand:n #1
{
\str_if_eq:nnF { #1 } { 0 }
{
\seq_put_right:Nx \l_aentropy_chisum_seq
{
\str_if_eq:nnF { #1 } { 1 } { #1 }
\exp_not:n { \chi }
\c_math_subscript_token
{ \int_to_arabic:n { \l_aentropy_chisum_index_int } }
}
}
}
Try with
$\chisum{5,2,7,8,2,0,0,1,3}$
$\chisum{a,b,2,0,0,0,0,1,3}$
and you'll get
