struct SimpleStatistics::Line
- SimpleStatistics::Line
- Struct
- Value
- Object
Overview
A struct representing a line in 2D space.
line = SimpleStatistics::Line.new(2, 3)
line.slope # => 2
line.intercept # => 3
line.at(5) # => 13
Defined in:
simple_statistics/Line.crConstructors
-
.new(m : Float64, b : Float64)
Creates a new
Linewith a slope and intercept.
Instance Method Summary
-
#at(x : Float64) : Float64
The
yat the givenx. -
#b : Float64
The intercept.
-
#intercept : Float64
The intercept.
-
#m : Float64
The slope.
-
#slope : Float64
The slope.
Constructor Detail
def self.new(m : Float64, b : Float64)
#
Creates a new Line with a slope and intercept.
line = SimpleStatistics::Line.new(4, 5)
line.slope # => 4
line.intercept # => 5
Instance Method Detail
def at(x : Float64) : Float64
#
The y at the given x.
line = SimpleStatistics::Line.new(2, 3)
line.at(0) # => 3
line.at(1) # => 5
line.at(1.2) # => 5.4
def intercept : Float64
#
The intercept. Alias of #b.
SimpleStatistics::Line.new(99, 2).intercept
# => 2