// Path: src/main/java/com/pearson/statspoller/utilities/core_utils/StackTrace.java
// public class StackTrace {
//     
//     private static final Logger logger = LoggerFactory.getLogger(StackTrace.class.getName());
//     
//     public static String getStringFromStackTrace(Exception exception) {
//         try {
//             StringWriter stringWriter = new StringWriter();
//             PrintWriter printWriter = new PrintWriter(stringWriter);
//             
//             exception.printStackTrace(printWriter);
//             
//             return stringWriter.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
//     public static String getStringFromStackTrace(StackTraceElement[] stackTraceElements) {
//         try {
//             
//             StringBuilder stackTrace = new StringBuilder();
//             
//             for (StackTraceElement stackTraceElement : stackTraceElements) {
//                 stackTrace.append(stackTraceElement).append(System.lineSeparator());
//             }
//             
//             return stackTrace.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
// }


import com.pearson.statspoller.utilities.core_utils.StackTrace;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
            }
            else {
                return number.setScale(scale, roundingMode);
            }
        }
        else {
            return number.setScale(scale, roundingMode);
        }
    }
    
    public static BigDecimal computePopulationStandardDeviationOfBigDecimals(List<BigDecimal> numbers) {
        
        if ((numbers == null) || numbers.isEmpty()) {
            return null;
        }
        
        try {
            double[] doublesArray = new double[numbers.size()];

            for (int i = 0; i < doublesArray.length; i++) {
                doublesArray[i] = numbers.get(i).doubleValue();
            }

            StandardDeviation standardDeviation = new StandardDeviation();
            standardDeviation.setBiasCorrected(false);
            BigDecimal standardDeviationResult = new BigDecimal(standardDeviation.evaluate(doublesArray));

            return standardDeviationResult;
        }
        catch (Exception e) {
// Path: src/main/java/com/pearson/statspoller/utilities/core_utils/StackTrace.java
// public class StackTrace {
//     
//     private static final Logger logger = LoggerFactory.getLogger(StackTrace.class.getName());
//     
//     public static String getStringFromStackTrace(Exception exception) {
//         try {
//             StringWriter stringWriter = new StringWriter();
//             PrintWriter printWriter = new PrintWriter(stringWriter);
//             
//             exception.printStackTrace(printWriter);
//             
//             return stringWriter.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
//     public static String getStringFromStackTrace(StackTraceElement[] stackTraceElements) {
//         try {
//             
//             StringBuilder stackTrace = new StringBuilder();
//             
//             for (StackTraceElement stackTraceElement : stackTraceElements) {
//                 stackTrace.append(stackTraceElement).append(System.lineSeparator());
//             }
//             
//             return stackTrace.toString();
//         }
//         catch (Exception e) {
//             logger.error(e.toString() + " - Failed to convert stack-trace to string");
//             return null;
//         }
//     }
//     
// }


// Path: src/main/java/com/pearson/statspoller/utilities/math_utils/MathUtilities.java
import com.pearson.statspoller.utilities.core_utils.StackTrace;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.math3.stat.descriptive.moment.StandardDeviation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

            }
            else {
                return number.setScale(scale, roundingMode);
            }
        }
        else {
            return number.setScale(scale, roundingMode);
        }
    }
    
    public static BigDecimal computePopulationStandardDeviationOfBigDecimals(List<BigDecimal> numbers) {
        
        if ((numbers == null) || numbers.isEmpty()) {
            return null;
        }
        
        try {
            double[] doublesArray = new double[numbers.size()];

            for (int i = 0; i < doublesArray.length; i++) {
                doublesArray[i] = numbers.get(i).doubleValue();
            }

            StandardDeviation standardDeviation = new StandardDeviation();
            standardDeviation.setBiasCorrected(false);
            BigDecimal standardDeviationResult = new BigDecimal(standardDeviation.evaluate(doublesArray));

            return standardDeviationResult;
        }
        catch (Exception e) {
            logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));