///|
pub struct BootstrapSummary {
  estimate : Double
  lower : Double
  upper : Double
  replicates : Int
} derive(Debug, Eq, ToJson, FromJson)

///|
pub fn BootstrapSummary::estimate(self : BootstrapSummary) -> Double {
  self.estimate
}

///|
pub fn BootstrapSummary::interval(self : BootstrapSummary) -> (Double, Double) {
  (self.lower, self.upper)
}

///|
pub fn BootstrapSummary::replicates(self : BootstrapSummary) -> Int {
  self.replicates
}

///|
pub fn bootstrap_mean(
  rng : DeterministicRng,
  values : Array[Double],
  replicates : Int,
) -> (DeterministicRng, BootstrapSummary) {
  if values.length() == 0 || replicates < 2 {
    abort("bootstrap_mean: invalid values or replicates")
  }
  let estimates = Array::make(replicates, 0.0)
  let mut current = rng
  for replicate in 0.. (DeterministicRng, Double) {
  if left.length() == 0 || right.length() == 0 || permutations <= 0 {
    abort("permutation_difference: invalid inputs")
  }
  let observed = mean(left) - mean(right)
  let combined = left.copy()
  for value in right {
    combined.push(value)
  }
  let indices = []
  for index in 0..= observed.abs() {
      exceed = exceed + 1
    }
  }
  (current, (exceed + 1).to_double() / (permutations + 1).to_double())
}