struct SimpleStatistics::Line

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.cr

Constructors

Instance Method Summary

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

[View source]

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

[View source]
def b : Float64 #

The intercept. Aliased as #intercept.

SimpleStatistics::Line.new(99, 2).b
# => 2

[View source]
def intercept : Float64 #

The intercept. Alias of #b.

SimpleStatistics::Line.new(99, 2).intercept
# => 2

[View source]
def m : Float64 #

The slope. Aliased as #slope.

SimpleStatistics::Line.new(4, 99).m
# => 4

[View source]
def slope : Float64 #

The slope. Alias of #m.

SimpleStatistics::Line.new(4, 99).slope
# => 4

[View source]