I'm looking for the correct way to define a sum of all elements in a set that fullfill a certain condition.

Example: $$ n(A) = \frac{\sum_{F \in A}{ \begin{cases} A_F\text{ is }\mathrm{NULL} & w_F\\ \text{else} & 0 \end{cases}}}{\sum_{F \in A}{w_F}} $$

A is to supposed to be a record with a number of fields $F$. $A_F$ is the value of field F in the record A. $w_F$ is a weight associated with the Field $F$. I want to calculate how much percent of the record is NULL weighted according to $w_F$.

What I want to know is if this below is a valid way to formulate this or if there is a better way.

If someone has some pointers on a more formal / mathematical notation for database/records I would also be very grateful.



Although I don't think it is quite mainstream, but you could look into Iverson Notation. In short, you have a bracket and inside you write a condition. The bracket value is 1 if the condition holds, otherwise it's 0. Its most popular usage was in Concrete Mathematics (by Knuth et al).

$$ n(A) = \frac{\sum_{F \in A}{w_F[A_F \neq NULL]}}{\sum_{F \in A}{w_F}} $$

  • $\begingroup$ I like this one. Looks very natural. I think I will go for this notation at least for the moment and hope that it's common enough for my professor to recognize it ;-) $\endgroup$ – aKzenT Jan 15 '12 at 20:06
  • $\begingroup$ @aKzenT Why possibly puzzle your professor? Define the notation you want to use. Footnote stackexchange and Knuth and s/he won't complain. (Just noticed that this is an ancient answer, so my comment isn't much help.) $\endgroup$ – Ethan Bolker Apr 27 '18 at 16:37

For the sake of clarity, I would describe such an operation with the help of a short sentence. Also, it is quite common to put some summation conditions in the index spot of the sum symbol, as in

$$\sum_{p \text{ prime}} 1/p$$

In my opinion, it is best to describe what you have written above as

(Brief description of what kinds of objects $A$, $w_F$, $A_f$, etc are and a quick name for what $n(A)$ describes)

$$n(A) = \sum_{F \in A, A_F = 0} w_F/\sum_{F \in A}w_F$$

  • $\begingroup$ I thought about this one, but I would like the condition to be a bit more visible instead of putting it only in the subscript of the sum. The formula is inside a larger text explaining the operation in text also, just like I did above. $\endgroup$ – aKzenT Jan 15 '12 at 20:04

I know it is not any cool notation, but maybe you can simply define a dummy set, one that satisfies all your conditions, and then, make the sum of wf on each element of this dummy set .

By adding a dummy set B, this part of your formula $$\sum_{F \in A}{ \begin{cases} A_F\text{ is }\mathrm{NULL} & w_F\\ \text{else} & 0 \end{cases}}$$

could be transformed into

$$ \sum_{F \in B}{w_F} $$ Then add at the end of your formula that set B is all the elements f of set A for which Af is null: $$B=\{f \in A | A_f\text{ is }\mathrm{NULL}\} $$

Thus, my final answer to your question would look like this: $$ n(A) = \frac{\sum_{F \in B}{w_F}}{\sum_{F \in A}{w_F}} $$ where

$$B=\{f \in A | A_f\text{ is }\mathrm{NULL}\} $$

**Also, I don't know yet if this notation is allowed: $$ n(A) = \frac{\sum_{F \in \{f \in A | A_f\text{ is }\mathrm{NULL}\}}{w_F}}{\sum_{F \in A}{w_F}} $$ but it is the integration of the B set definition into one big formula. I personnaly think that defining B on a separated formula is clearer, but I guess sometimes we need to use only one formula.

  • $\begingroup$ Welcome to stackexchange. I'm glad you want to help by providing answers, but working a five year old question with an accepted answer isn't likely to be useful. You'd be better off spending your time on new questions that have no good answers. $\endgroup$ – Ethan Bolker Apr 27 '18 at 16:41
  • 1
    $\begingroup$ Thank you! As a Google wanderer myself, I believe that any solution may help many of my fellow wanderers. I know this question is old, but I try to make internet a better place everyday. I may be not advanced enough in mathematics to formulate excellent answers to many specific questions, but I will sure be glad to help if I find the opportunity. $\endgroup$ – V. Brunelle Apr 27 '18 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.