3. Consider the pseudo code to calculate the mean and standard deviation of a data set given in Figure 4. Select a scripting 3. Consider the pseudo code to calculate the mean and standard deviation of a data set given in Figure 4. Select a scripting language to work with. Generate a set of random data with a mean of your choice and 1 million data points. Implement both algorithms in Figure 4 to calculate the mean and standard deviation. Do you get identical answers? Provide your commented code and answers. Explain your results. variance(samples): sum := 0 sumsq := 0 for x in samples: sum := sum + x sumsg := sums + ***2 mean := sum/N return (sumsq – N*mean**2)/(N-1) variance(samples): M := 0 S := 0 for k from 1 to N: x := samples[k] oldM := M M := M + (x-M)/k S :5 + (x-M)*(x-old) return S/(N-1) Figure 4: Pseudocode of an offline program to calculate the mean and standard deviation (left), and pseudocode of an online program to calculate the mean and standard deviation attributed to Knuth and Welford Welford, 1962) (right).



Source link

Leave a Reply

Your email address will not be published.