export function is_object(x) {
  return x !== null && typeof x === "object" && !Array.isArray(x)
}

export function sum(nums) {
  return nums.reduce((s, n) => s + n, 0)
}

export function mean(nums) {
  return sum(nums) / nums.length
}

export function pstdev(nums, mu = null) {
  if (mu === null) {
    mu = mean(nums)
  }
  return Math.sqrt(mean(nums.map((n) => (n - mu) ** 2)))
}
