Finding the mean using RxJava I'm learning RxJava and this is what I attempted to find the mean of 'n' transactions.

List&lt;Transaction&gt; transactions = TransactionsStore.getTransactions();
BigDecimal nTransactions = new BigDecimal(transactions.size());
Observable.from(transactions)
        .map(transaction -&gt; transaction.amount)
        .reduce(BigDecimal::add)
        .map(total -&gt; total.divide(nTransactions, 2, BigDecimal.ROUND_DOWN))
        .map(mean -&gt; String.format("The mean is %s", mean.toPlainString()))
        .subscribe(System.out::println);


I'd like to know if this could be done better.
Using RxJava-Math you can achieve the same result by this way:

List&lt;Transaction&gt; transactions = createRandomTransactions(10);

final Observable&lt;Float&gt; amountStream = Observable.from(transactions)
        .map(transaction -&gt; transaction.amount);

MathObservable.averageFloat(amountStream)
        .map(mean -&gt; String.format(Locale.US, "The mean is %.2f", mean))
        .subscribe(System.out::println);


Hope that helps!