Question: How to implement the function of variance by using sml? The variance of a list of reals [x_1, .....x_n]can be the average of the squares
How to implement the function of variance by using sml?

The variance of a list of reals [x_1, .....x_n]can be the average of the squares minus the square of the average. One formula for computing variance is var(x) = sigma^n_i=1 x^2_i - (sigma^n_i=1 Use function square, built-in functions length and map and function sum in (e) to implement an ML function variance to return the variance of the input list. Function square is defined as fun square(x:real) = x*x; val square = fn: real rightarrow real
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
