📜  bash 计算列的标准差 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:48.894000             🧑  作者: Mango

代码示例1
# Example usage:
awk '{delta = $1 - avg; avg += delta / NR; mean2 += delta * ($1 - avg); } END { print sqrt(mean2 / NR); }' input_file
# This produces the standard deviation for column 1. Change the 1s to
# whichever column number you want.

# Example usage 2:
awk ‘{delta = $1 – avg; avg += delta / NR; mean2 += delta * ($1 – avg); } END { print sqrt(mean2 / (NR-1)); }’ input_file
# This is the calculation for a sample instead of a population