ExLTTB v0.2.0 ExLTTB.SampleUtils View Source

Utility functions to perform common operations on generic samples

Link to this section Summary

Functions

Returns the average sample of a list of sample

Returns the area of the triangle defined by s1, s2 and s3

Link to this section Functions

Link to this function average_sample(samples, opts \\ []) View Source

Returns the average sample of a list of sample.

Arguments

  • samples: a list of samples. These can have any representation provided that access functions are provided (see Options)
  • opts: a keyword list of options

Options

  • sample_to_x_fun: a function that takes as argument a sample and returns its x coordinate. Defaults to sample[:x]
  • sample_to_y_fun: a function that takes as argument a sample and returns its y coordinate. Defaults to sample[:y]
  • xy_to_sample_fun: a function that takes as argument x and y and returns a sample with these coordinates. Defaults to %{x: x, y: y}
Link to this function triangle_area(s1, s2, s3, opts) View Source

Returns the area of the triangle defined by s1, s2 and s3.

Arguments

  • s1, s2, s3: the vertices of the triangle. These can have any representation provided that access functions are provided (see Options)
  • opts: a keyword list of options

Options

  • sample_to_x_fun: a function that takes as argument a sample and returns its x coordinate. Defaults to sample[:x]
  • sample_to_y_fun: a function that takes as argument a sample and returns its y coordinate. Defaults to sample[:y]
  • xy_to_sample_fun: a function that takes as argument x and y and returns a sample with these coordinates. Defaults to %{x: x, y: y}