# fn:avg - XPath XQuery Reference

Returns the average of the values in the input sequence $arg, that is, the
            sum of the values divided by the number of values.deterministiccontext-independentfocus-independentIf $arg is the empty sequence, the empty sequence is returned.If $arg contains values of type xs:untypedAtomic they are cast
            to xs:double. Duration values must either all be xs:yearMonthDuration values or must all
            be xs:dayTimeDuration values. For numeric values, the numeric promotion
            rules defined in  are used to promote all values to a single
            common type. After these operations, $arg must satisfy the following condition:There must be a type T such that:every item in $arg is an instance of T.T is one of xs:double, xs:float,
                  xs:decimal, xs:yearMonthDuration, or
                  xs:dayTimeDuration.The function returns the average of the values as sum($arg) div
            count($arg); but the implementation may use an otherwise equivalent algorithm
            that avoids arithmetic overflow.fn:avg($seq3)4.0The result is of type xs:decimal.fn:avg(($d1, $d2))xs:yearMonthDuration("P10Y5M")fn:avg(($d1, $seq3)) raises a type error . fn:avg(())()fn:avg((xs:float('INF'), xs:float('-INF')))xs:float('NaN')fn:avg(($seq3, xs:float('NaN')))xs:float('NaN')A type error is raised  if the input sequence contains
            items of incompatible types, as described above.