Package-level declarations

Types

Link copied to clipboard
class CSVRowIterator(val pathToFile: Path, csvParser: CSVParser = CSVParser(FileReader(pathToFile.toFile()), CSVFormat.DEFAULT)) : Iterator<CSVRecord> , Closeable

Returns an iterator to the rows of a csv file that may have the first row as a header of column labels and each subsequent row as the data for each column, e.g. "x", "y" 1.1, 2.0 4.3, 6.4 etc.

Link copied to clipboard
object CSVUtil

A class to facilitate some basic CSV processing without having to worry about underlying csv library. Helps with reading and writing arrays to csv files. Generally, exceptions are squashed.

Link copied to clipboard
Link copied to clipboard
object ExcelUtil
Link copied to clipboard
object KSL
Link copied to clipboard

Provides some basic file utilities. Additional utilities can be found in Google Guava and Apache Commons IO. However, this basic IO provides basic needs without external libraries and is integrated withe KSL functionality.

Link copied to clipboard

A wrapper for a PrintWriter. This class has all the functionality of PrintWriter but has a public property OUTPUT_ON that can be set to false to turn off any printing or set to true to turn printing on.

Link copied to clipboard
object MarkDown

A class to facilitate construction of markdown elements

Link copied to clipboard
class OutputDirectory(outputDirectoryPath: Path = KSLFileUtil.programLaunchDirectory, outFileName: String = "out.txt")

This class provides basic context for creating and writing output files. Files and directories created by instances of this class will be relative to the Path supplied at creation.

Link copied to clipboard
class StatisticReporter(listOfStats: MutableList<StatisticIfc> = ArrayList())

A class to help with making useful statistical reports. Creates summary reports as StringBuilders based on the supplied list of statistics

Link copied to clipboard
interface StatSchema

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun AnyFrame.addColumnsFor(linearModel: LinearModel): AnyFrame

Causes the columns associated with the linear model to be added to the dataframe.

Link copied to clipboard
fun <T> DataFrame<T>.asMarkDownTable(): String
Link copied to clipboard
fun DataColumn<Double>.boxPlotSummary(name: String? = this.name()): BoxPlotSummary
Link copied to clipboard
fun AnyFrame.boxPlotSummaryData(): DataFrame<BoxPlotDataIfc>

Creates a dataframe that holds the box plot summary data for any column that holds Double type within the original dataframe.

Link copied to clipboard
fun DataColumn<Double>.frequenciesD(name: String? = this.name()): IntegerFrequency
Link copied to clipboard
fun DataColumn<Int>.frequenciesI(name: String? = this.name()): IntegerFrequency
Link copied to clipboard
fun AnyFrame.hasAllColumns(list: List<AnyCol>): Boolean

True if the dataframe contains all the columns in the list. False if at least one column is not in the dataframe.

Link copied to clipboard
fun AnyFrame.hasAllNamedColumns(columnNames: List<String>): Boolean

True if the dataframe contains all the named columns in the list. False if at least one column is not in the dataframe.

Link copied to clipboard
fun DataColumn<Double>.histogram(breakPoints: DoubleArray = Histogram.recommendBreakPoints(this.toDoubleArray()), name: String? = this.name()): Histogram
Link copied to clipboard
fun main()
fun main()
Link copied to clipboard
fun AnyFrame.multiply(columns: List<DataColumn<Double>>): AnyFrame

Causes a new column to be added to the dataframe that represents the element-wise multiplication of the columns in the list. The columns must be in the dataframe.

fun AnyFrame.multiply(colAName: String, colBName: String): AnyFrame

Causes a new column to be added to the dataframe that represents the element-wise multiplication of column A and B. The columns must be in the data frame and be of type DataColumn

fun AnyFrame.multiply(colA: DataColumn<Double>, colB: DataColumn<Double>): AnyFrame

Causes a new column to be added to the dataframe that represents the element-wise multiplication of column A and B. The columns must be in the dataframe.

Link copied to clipboard
fun AnyFrame.multiplyColumns(columnNames: List<String>): AnyFrame

Causes a new column to be added to the dataframe that represents the element-wise multiplication of the columns in the list. The columns must be in the dataframe and the columns must hold Double values.

Link copied to clipboard
fun <T> DataFrame<T>.permute(streamNum: Int): DataFrame<T>
fun <T> DataFrame<T>.permute(stream: RNStreamIfc = KSLRandom.defaultRNStream()): DataFrame<T>
Link copied to clipboard
Link copied to clipboard
fun printf(fmt: String, vararg args: Any?)

Wraps String.format() to print a formatted string. The fmt string must be valid for String.format()

Link copied to clipboard
fun <T> DataFrame<T>.randomlySelect(streamNum: Int): DataRow<T>
fun <T> DataFrame<T>.randomlySelect(stream: RNStreamIfc = KSLRandom.defaultRNStream()): DataRow<T>
Link copied to clipboard
fun <T> DataFrame<T>.sample(stream: RNStreamIfc = KSLRandom.defaultRNStream()): DataRow<T>

Randomly samples a row from the data frame (with replacement).

fun <T> DataFrame<T>.sample(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): DataFrame<T>

The data frame, is not changed. The returned data frame holds a sample of the rows, with replacement. The rows may repeat.

Link copied to clipboard
fun <T> DataFrame<T>.sampleWithoutReplacement(sampleSize: Int, streamNum: Int): DataFrame<T>
fun <T> DataFrame<T>.sampleWithoutReplacement(sampleSize: Int, stream: RNStreamIfc = KSLRandom.defaultRNStream()): DataFrame<T>

The data frame, is not changed. The returned data frame holds a sample of the rows.

Link copied to clipboard
fun DataColumn<Double>.statistics(name: String? = this.name()): Statistic

fun AnyFrame.statistics(level: Double = 0.95): DataFrame<StatisticData>

Creates a dataframe that holds the statistical data for any column that holds Double type within the original dataframe. The confidence interval level is by default 0.95.

Link copied to clipboard
fun AnyFrame.summaryStatistics(): DataFrame<SummaryStatisticsIfc>

Creates a dataframe that holds the summary statistical data for any column that holds Double type within the original dataframe.

Link copied to clipboard
fun AnyRow.toCSV(separator: String = ","): String

Converts the DataRow to a string separated by the provided separator. The default is common separated. Elements in the row that are strings are enclosed in double quotes to permit the separator to appear in the string.

fun AnyFrame.toCSV(appendable: Appendable, header: Boolean = true, separator: String = ",")

Converts the data frame to rows of comma separated file output with specified separator. The default separator is a comma. Elements that are strings are enclosed in double quotes to permit the separator to appear in the element. If the header is true, then the column names of the dataframe are included as the first row before any data rows are appended.

Link copied to clipboard
fun Array<DoubleArray>.toDataFrame(): AnyFrame

Converts the 2-D array of doubles to a data frame. The column names are col1, col2, col3, etc. The 2D array must be rectangular

fun Map<String, DoubleArray>.toDataFrame(): AnyFrame

Converts the data stored in each array to columns within a DataFrame, with the column names as the key from the map and the columns holding the data. Each array must have the same size.

Converts the box plot summary data to a data frame with two columns. The first column holds the name of the statstics and the second column holds the values.

Converts the histogram bin data into a dataframe representation

Converts the integer frequency data into a dataframe representation

Link copied to clipboard
fun StatisticIfc.toStatDataFrame(valueLabel: String = "Value"): DataFrame<StatSchema>

Converts a statistic to a data frame with two columns. The first column holds the names of the statistics and the second column holds the values. The valueLabel can be used to provide a column name for the value columns. By default, it is "Value".

Link copied to clipboard
fun AnyFrame.toTabularFile(pathToFile: Path): TabularFile

Convert the dataframe to a TabularOutputFile at the supplied path

fun AnyFrame.toTabularFile(fileName: String): TabularFile

Convert the dataframe to a TabularOutputFile with the supplied file name within KSL.outDir

Link copied to clipboard
fun Array<IntArray>.write(out: PrintWriter = KSLFileUtil.SOUT)
fun IntArray.write(out: PrintWriter = KSLFileUtil.SOUT)
fun Array<DoubleArray>.write(out: PrintWriter = KSLFileUtil.SOUT, df: DecimalFormat? = null)
fun DoubleArray.write(out: PrintWriter = KSLFileUtil.SOUT, df: DecimalFormat? = null)
fun List<DoubleArray>.write(out: PrintWriter = KSLFileUtil.SOUT, df: DecimalFormat? = null)
Link copied to clipboard
fun <T> DataFrame<T>.writeMarkDownTable(writer: PrintWriter = KSL.createPrintWriter("dataFrame.md"))
Link copied to clipboard
fun Array<IntArray>.writeToFile(pathToFile: Path)
fun IntArray.writeToFile(pathToFile: Path)
fun IntArray.writeToFile(fileName: String)
fun Array<DoubleArray>.writeToFile(pathToFile: Path, df: DecimalFormat? = null)
fun Array<DoubleArray>.writeToFile(fileName: String, df: DecimalFormat? = null)
fun DoubleArray.writeToFile(pathToFile: Path, df: DecimalFormat? = null)
fun DoubleArray.writeToFile(fileName: String, df: DecimalFormat? = null)