Mean value of positive numbers in an arbitrary set of numbers

106 Views Asked by At

I have a set with an arbitrary amount of positive and negative numbers. Now I want to calculate the mean value of all numbers inside the set which are greater than $0$. Is there a mathematical way of expressing the amount of number inside a set?

I would write the mean calculation as follows:

$$d = \dfrac{\sum\limits_{i=0}^{n}element_i \text{ where }\ element_i \in \mathbb{N^*}}{n}$$

So how is the mathematical correct way of expressing the correct amount of $n$?

2

There are 2 best solutions below

0
On

Suppose that $A$ is your set. Let $B = \{x \in A \mid x >0\}$. Then your required average is just $$ \frac{\operatorname{sum}(B)}{|B|} $$

0
On

Indicator notation: https://en.wikipedia.org/wiki/Indicator_function

Indicators are functions which return 1 if a condition is met and 0 if it is not.

So you would have: $d = \dfrac{\sum\limits_{i=0}^{n}element_i * 1_{element_i \in \mathbb{N^*}}}{\sum\limits_{i=0}^{n}1_{element_i \in \mathbb{N^*}}}$