1 You can find the linspace
specification in the breeze package object linalg
and plot
is in the package object plog
:
http://www.scalanlp.org/api/index.html#breeze.linalg.package https://github.com/scalanlp/breeze/blob/master/math/src/main/scala/breeze/linalg/package.scala#L127
/**
* Generates a vector of linearly spaced values between a and b (inclusive).
* The returned vector will have length elements, defaulting to 100.
*/
def linspace(a : Double, b : Double, length : Int = 100) : DenseVector[Double] = {
val increment = (b - a) / (length - 1)
DenseVector.tabulate(length)(i => a + increment * i)
}
http://www.scalanlp.org/api/index.html#breeze.plot.package https://github.com/scalanlp/breeze/blob/master/viz/src/main/scala/breeze/plot/package.scala#L24
/**
* Plots the given y versus the given x with the given style.
*
* @param x X-coordinates, co-indexed with y (and indexed by keys of type K).
* @param y Y-coordinates, co-indexed with x (and indexed by keys of type K).
* @param style Matlab-like style spec of the series to plot.
* @param name Name of the series to show in the legend.
* @param labels Optional in-graph labels for some points.
* @param tips Optional mouse-over tooltips for some points.
*/
def plot[X,Y,V](x: X, y: Y, style : Char = '-', colorcode : String = null, name : String = null,
lines : Boolean = true, shapes : Boolean = false,
labels : (Int) => String = null.asInstanceOf[Int=>String],
tips : (Int) => String = null.asInstanceOf[Int=>String] )
(implicit xv: DomainFunction[X,Int,V],
yv: DomainFunction[Y, Int, V], vv: V=>Double):Series = new Series {
...
2 This is element wise exponentiation. So x :^ 3.0
would return x with every element to the third power. In the example given, x is a DenseVector
of 100 values between 0 and 1. so x :^ 3.0
would give you another DenseVector
of 100 values between 0 and 1, but they are taken to the third power, which makes a nice graph.