A brief description of every exported name in every library of the robin namespace of r7rs-libs.

(robin abbrev)

[procedure] abbrev
Definition

(abbrev strings [prefix])

Description
  • strings - a list of strings to analyse

  • prefix - an optional string prefix, required on output abbreviations

Returns a list of (abbreviation . string) dotted pairs, where each string is in the original list of strings, and each abbreviation is a unique abbreviation for that string.

(robin confusion-matrix)

[procedure] make-confusion-matrix
Definition

(make-confusion-matrix [labels])

Documentation
  • labels - optional list of labels to use to create confusion matrix. Defaults to 'positive 'negative.

Returns a new confusion matrix instance. Labels should be strings or symbols.

Error

If less than two labels are given.

[procedure] confusion-matrix?
Definition

(confusion-matrix? value)

Documentation
  • value - a value

Returns #t if value is a confusion matrix instance.

[procedure] confusion-matrix-add
Definition

(confusion-matrix-add cm predicted observed [total])

Documentation
  • cm - confusion matrix

  • predicted - predicted label of instance

  • observed - observed label of instance

  • total - optional number of instances to add, default value is 1

Adds total to the count for given (predicted observed) labels.

Error

If cm is not a confusion matrix instance or if labels are not part of the confusion matrix.

[procedure] confusion-matrix-count
Definition

(confusion-matrix-count cm predicted observed)

Documentation
  • cm - confusion matrix

  • predicted - predicted label of instance

  • observed - observed label of instance

Returns the count for given (predicted observed) labels.

Error

If cm is not a confusion matrix instance. or if labels are not part of the confusion matrix.

[procedure] confusion-matrix-display
Definition

(confusion-matrix-display cm)

Documentation
  • cm - confusion matrix

Displays given confusion matrix to current-output port.

Error

If cm is not a confusion matrix instance.

[procedure] confusion-matrix-labels
Definition

(confusion-matrix-labels cm)

Documentation
  • cm - confusion matrix

Returns the labels for the confusion matrix.

Error

If cm is not a confusion matrix instance.

[procedure] confusion-matrix-total
Definition

(confusion-matrix-total cm)

Documentation
  • cm - confusion matrix

Returns the total number of instances referenced in the confusion matrix.

Error

If cm is not a confusion matrix instance.

[procedure] cohen-kappa
Definition

(cohen-kappa cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns Cohen’s Kappa statistic, which compares observed accuracy with an expected accuracy.

Error

If cm is not a confusion matrix instance.

[procedure] f-measure
Definition

(f-measure cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns harmonic mean of the precision and recall for the given label.

Error

If cm is not a confusion matrix instance.

[procedure] false-negative
Definition

(false-negative cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns the number of instances of the given label which are incorrectly observed.

Error

If cm is not a confusion matrix instance.

[procedure] false-positive
Definition

(false-positive cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns the number of incorrectly observed instances of the given label.

Error

If cm is not a confusion matrix instance.

[procedure] false-rate
Definition

(false-rate cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns proportion of instances of label incorrectly observed out of all instances not originally of that label.

Error

If cm is not a confusion matrix instance.

[procedure] geometric-mean
Definition

(geometric-mean cm)

Documentation
  • cm - confusion matrix

Returns nth root of product of true-rate for each label.

Error

If cm is not a confusion matrix instance.

[procedure] matthews-correlation
Definition

(matthews-correlation cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns measure of the quality of binary classifications.

Error

If cm is not a confusion matrix instance.

[procedure] overall-accuracy
Definition

(overall-accuracy cm)

Documentation
  • cm - confusion matrix

Returns proportion of instances which are correctly labelled.

Error

If cm is not a confusion matrix instance.

[procedure] precision
Definition

(precision cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns proportion of instances of given label which are correct.

Error

If cm is not a confusion matrix instance.

[procedure] prevalence
Definition

(prevalence cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns proportion of instances observed of given label, out of total.

Error

If cm is not a confusion matrix instance.

[procedure] recall
Definition

(recall cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns recall value, which is equal to the true-rate, for a given label.

Error

If cm is not a confusion matrix instance.

[procedure] sensitivity
Definition

(sensitivity cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns sensitivity value, which is another name for the true-rate (recall), for a given label.

Error

If cm is not a confusion matrix instance.

[procedure] specificity
Definition

(specificity cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns specificity, which is 1 - false-rate, for a given label.

Error

If cm is not a confusion matrix instance.

[proportion] true-negative
Definition

(true-negative cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns the number of instances NOT of the given label which are correctly observed.

Error

If cm is not a confusion matrix instance.

[procedure] true-positive
Definition

(true-positive cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns the number of instances of the given label correctly observed.

Error

If cm is not a confusion matrix instance.

[procedure] true-rate
Definition

(true-rate cm [for-label])

Documentation
  • cm - confusion matrix

  • for-label - optional class label to use as 'positive' - defaults to first label in definition

Returns proportion of instances of given label which are correctly observed.

Error

If cm is not a confusion matrix instance.

(robin csv)

[procedure] make-csv-reader
Definition

(make-csv-reader [port separator quotechar])

Description
  • port - an optional input port, defaults to current-input-port

  • separator - an optional separator character, defaults to #\,

  • quotechar - an optional quote character, defaults to #\"

Returns a CSV reader with given parameters. The caller is responsible for closing the port, when finished.

Error

If port is not an input-port, or separator and quotechar are not characters.

[procedure] csv-read
Definition

(csv-read [csv-reader])

Description
  • csv-reader - an optional csv reader, as created with make-csv-reader, defaults to reading from current-input-port

Returns a list of fields, or eof if the input-port is empty or at end.

[procedure] csv-read-all
Definition

(csv-read-all [csv-reader])

Description
  • csv-reader - an optional csv reader, as created with make-csv-reader, defaults to reading from current-input-port

Returns a list of lists of fields, read from input-port using csv-read until input-port is empty.

[procedure] make-csv-writer
Definition

(make-csv-writer [port separator quotechar])

Description
  • port - an optional output port, defaults to current-output-port

  • separator - an optional separator character, defaults to #\,

  • quotechar - an optional quote character, defaults to #\"

Returns a CSV writer with given parameters. The caller is responsible for closing the port, when finished.

Error

If port is not an output-port, or separator and quotechar are not characters.

[procedure] csv-write
Definition

(csv-write line [csv-writer])

Description
  • line - a list of fields to write as a single CSV record

  • csv-writer - an optional csv writer, as created with make-csv-writer, defaults to writing to current-output-port

Writes the given line as a CSV record to the writer.

[procedure] csv-write-all
Definition

(csv-write-all data [csv-writer])

Description
  • data - a list of lists of fields to write as separate CSV records

  • csv-writer - an optional csv writer, as created with make-csv-writer, defaults to writing to current-output-port

Writes the given data as a series of CSV records to the writer.

(robin disjoint-set)

[procedure] make-disjoint-set
Definition

(make-disjoint-set comparator)
(make-disjoint-set equality? hash-function)

Description
  • comparator - a (scheme comparator) comparator

or

  • equality? - an equality procedure

  • hash-function - a hash function

Returns a new disjoint-set object.

[procedure] disjoint-set?
Definition

(disjoint-set? object)

Description
  • object - some Scheme value

Returns #t if the given object is a disjoint-set, or else #f.

[procedure] disjoint-set:find
Definition

(disjoint-set:find disjoint-set item [default])

Description
  • disjoint-set - a disjoint-set object

  • item - the item to locate within the disjoint-set

  • default - default value to return if not found

Returns a representative item in the disjoint set for the given item. Returns the optional default value, or the symbol item-not-found, if no set is found.

Error

If an invalid disjoint-set is provided.

[procedure] disjoint-set:make
Definition

(disjoint-set:make disjoint-set item)

Description
  • disjoint-set - a disjoint-set object

  • item - the item to use as the base for a new group within the disjoint-set

Includes the given item in the disjoint set as its own group. No useful return value.

Error

If an invalid disjoint-set is provided.

[procedure] disjoint-set:size
Definition

(disjoint-set:size disjoint-set item)

Description
  • disjoint-set - a disjoint-set object

Returns the number of distinct groups in the disjoint set.

Error

If an invalid disjoint-set is provided.

[procedure] disjoint-set:union
Definition

(disjoint-set:union disjoint-set item-1 item-2)

Description
  • disjoint-set - a disjoint-set object

  • item-1 - representative of one group in the disjoint set

  • item-2 - representative of a second group in the disjoint set

Modifies the disjoint set so the two represented groups are equivalent.

Error

If an invalid disjoint-set is provided, or either of the given items is not found.

(robin simulated-annealing)

[procedure] simulated-annealing
Definition

(simulated-annealing make-instance evaluate-instance num-iterations [can-stop?])

Description
  • make-instance - a procedure to return a new instance in the search domain. If an optional instance is provided, then the new instance should be a neighbour of the given instance

  • evaluate-instance - a procedure of one argument, an instance in the search domain. Returns a positive number evaluating the instance, with 0 representing the best evaluation

  • num-iterations - the number of iterations over which the search is performed

  • can-stop? - an optional procedure of one argument, the current instance’s evaluation. Returns #t if the search should stop prematurely, e.g. if a solution is found.

Returns the best instance found after performing simulated-annealing stochastic search.

Error

If num-iterations or evaluate-instance are not of the appropriate type.

(robin srfi64-utils)

[procedure] test-all-equal
Definition

(test-all-equal proc pairs)

Description
  • proc - a procedure accepting one argument

  • pairs - a list of dotted (argument . result) pairs

Calls test-equal on each pair, as (test-equal result (proc argument)).

[procedure] test-compare
Definition

(test-compare proc item-1 item-2)

Description
  • proc - a comparison procedure accepting two arguments

  • item-1 - one item to be compared

  • item-2 - a second item to be compared

Calls test-assert on the result of applying proc to the two items.

[syntax] test-no-error
Definition

(test-no-error code)

Description
  • code - a block of test code to evaluate

Test fails if the given code raises an error.

(robin statistics)

[procedure] mean
Definition

(mean list-numbers)

Same as arithmetic-mean.

[procedure] arithmetic-geometric-mean
Definition

(arithmetic-geometric-mean x y [tolerance])

Description
  • x - first number

  • y - second number

  • tolerance - optional tolerance, defaults to 1e-8.

Returns the arithmetic-geometric mean of the given two numbers.

[procedure] arithmetic-mean
Definition

(arithmetic-mean list-numbers)

Description
  • list-numbers - list of numbers

Returns the arithmetic mean of given list of numbers.

[procedure] geometric-mean
Definition

(geometric-mean list-numbers)

Description
  • list-numbers - list of numbers

Returns the geometric mean of given list of numbers.

[procedure] harmonic-mean
Definition

(harmonic-mean list-numbers)

Description
  • list-numbers - list of numbers

Returns the harmonic mean of given list of numbers.

[procedure] median
Definition

(median list-numbers)

Description
  • list-numbers - list of numbers

Returns the median value of given list of numbers.

[procedure] mode
Definition

(mode list-numbers)

Description
  • list-numbers - list of numbers

Returns the modal value of given list of numbers.

Error

If the given list of numbers is empty.

[procedure] percentile
Definition

(percentile list-numbers percent)

Description
  • list-numbers - list of numbers

  • percent - percentile value, integer in range 1 to 99, inclusive

Returns the value of given list of numbers at the given percentile.

Error

If the given list of numbers is empty or percent is not in range.

[procedure] population-standard-deviation
Definition

(population-standard-deviation list-numbers [mean])

Description
  • list-numbers - list of numbers

  • mean - optional value of mean, to avoid recalculation

Returns population standard deviation of given list of numbers.

[procedure] population-variance
Definition

(population-variance list-numbers [mean])

Description
  • list-numbers - list of numbers

  • mean - optional value of mean, to avoid recalculation

Returns population variance of given list of numbers.

[procedure] standard-deviation
Definition

(standard-deviation list-numbers [mean])

Description
  • list-numbers - list of numbers

  • mean - optional value of mean, to avoid recalculation

Returns standard deviation of given list of numbers.

[procedure] variance
Definition

(variance list-numbers [mean])

Description
  • list-numbers - list of numbers

  • mean - optional value of mean, to avoid recalculation

Returns variance of given list of numbers.

[procedure] coefficient-of-variation
Definition

(coefficient-of-variation list-numbers)

Description
  • list-numbers - list of numbers

Returns coefficient of variation of given list of numbers.

[procedure] standard-error-of-the-mean
Definition

(standard-error-of-the-mean list-numbers)

Description
  • list-numbers - list of numbers

Returns standard-error of the mean of given list of numbers.

[procedure] combinations
Definition

(combinations n k)

Description
  • n - positive integer, size of set

  • k - positive integer, number to select

Returns the number of ways to take k things from n without replacement when order does not matter.

[procedure] permutations
Definition

(permutations n k)

Description
  • n - positive integer, size of set

  • k - positive integer, number to select

Returns the number of ways to take k things from n without replacement when order does matter.

[procedure] sign
Definition

(sign x)

Description
  • x - a number

Returns 0 if x is zero, -1 if x is negative, or 1 if x is positive. Returns () if x is not a number.

[procedure] perlin-noise
Definition

(perlin-noise x-in y-in z-in)

Description
  • x-in - x coordinate in range 0 to 255

  • y-in - y coordinate in range 0 to 255

  • z-in - z coordinate in range 0 to 255

Returns a noise value for (x, y, z) value, based on http://mrl.nyu.edu/~perlin/noise/

[procedure] random-normal
Definition

(random-normal mu sigma)

Description
  • mu - mean value for Normal distribution

  • sigma - standard deviation for Normal distribution

Returns a random number, normally distributed with given mean and standard-deviation.

[procedure] random-pick
Definition

(random-pick list-items)

Description
  • list-items - list of items

Returns a random item from given list, or #f if list is empty or argument is not a list.

[procedure] random-sample
Definition

(random-sample n list-items)

Description
  • n - number of items to select

  • list-items - list of items

Returns two values: a random sample of n items from given list without replacement, and the remaining items. If n is greater than the size of the list, returns the items in the list in a random order.

Example
gosh[r7rs.user]$ (random-sample 3 '(1 2 3 4 5 6))
(6 5 4)
(1 2 3)
gosh[r7rs.user]$ (random-sample 30 '(1 2 3 4 5 6))
(2 1 5 4 3 6)
()
[procedure] random-weighted-sample
Definition

(random-weighted-sample n list-items list-weights)

Description
  • n - number of items to select

  • list-items - list of items

  • list-weights - list of numeric values given weight for each item

Returns a random sample of n items from given list without replacement, using given weighting.

[procedure] shuffle
Definition

(shuffle list-items)

Description
  • list-items - list of items

Returns the items of the list in a random order.

[procedure] jaccard-index
Definition

(jaccard-index items-1 items-2 [equals?])

Description
  • items-1 - list of items, treated as a set

  • items-2 - list of items, treated as a set

  • equals? - optional equals test, defaults to equal?

Returns the Jaccard Index comparing the two sets of items.

[procedure] jaccard-distance
Definition

(jaccard-distance items-1 items-2 [equals?])

Description
  • items-1 - list of items, treated as a set

  • items-2 - list of items, treated as a set

  • equals? - optional equals test, defaults to equal?

Returns the Jaccard Distance comparing the two sets of items.

[procedure] sorenson-dice-index
Definition

(sorenson-dice-index items-1 items-2 [equals?])

Description
  • items-1 - list of items, treated as a set

  • items-2 - list of items, treated as a set

  • equals? - optional equals test, defaults to equal?

Returns the Sorenson Dice Index comparing the two sets of items.

(robin text)

[procedure] word-wrap
Definition

(word-wrap str width)

Description
  • str - given string to convert into lines, should not contain newline characters.

  • width - the maximum length for a returned line.

Returns a list of strings, each string up to the given width in length. Words are split on ASCII spaces.

[procedure] words→with-commas

(words→with-commas words [add-comma?])

Description
  • words - a list of strings, each string being a term to join with commas

  • add-comma? - optional flag to indicate if there should be a comma before the final "and".

Returns a string with each word separated by a comma, except for the last pair which uses "and".

[procedure] string→n-grams
Definition

(string→n-grams str n)

Description
  • str - string to convert to n-grams

  • n - size of n-gram

Returns a list of strings, each string of size n characters.

Error

If n is not >= 1.

[procedure] daitch-mokotoff-soundex
Definition

(daitch-mokotoff-soundex word [option])

Description
  • word - string representing word to analyse

  • option - optional flag to indicate if single or multiple values should be returned, defaults to the symbol single, with any other value meaning multiple.

Returns one or more phonetic representations of the given word, based on the table at http://www.jewishgen.org/InfoFiles/soundex.html

[procedure] metaphone
Definition

(metaphone word)

Description
  • word - string representing word to analyse

Returns phonetic representation of the given word, based on the description at http://aspell.net/metaphone/metaphone-kuhn.txt

[procedure] russell-soundex
Definition

(russell-soundex word)

Same as soundex.

[procedure] soundex
Definition

(soundex word)

Description
  • word - string representing word to analyse

Returns a phonetic representation of the given word, using the soundex algorithm (from Knuth, Vol. 3 "Sorting and searching", pp 391—​2).

[procedure] hamming-distance
Definition

(hamming-distance item-1 item-2 [equals?])

Description
  • item-1 - first sequence

  • item-2 - second sequence

  • equals? - optional equality operator for items of sequence

Returns the hamming distance between the two given sequences, which is the number of substitutions required to convert the first sequence into the second.

Error

If two given sequences:

  • are not string, list, vector or bytevector,

  • are different types, or

  • are different sizes.

[procedure] levenshtein-distance
Definition

(levenshtein-distance item-1 item-2 [equals?])

Description
  • item-1 - first sequence

  • item-2 - second sequence

  • equals? - optional equality operator for items of sequence

Returns the levenshtein distance between the two given sequences, which is the number which is the number of substitutions/deletions/insertions required to convert the first sequence into the second.

Error

If two given sequences:

  • are not string, list, vector or bytevector,

  • are different types, or

  • are different sizes.

[procedure] optimal-string-alignment-distance
Definition

(optimal-string-alignment-distance item-1 item-2 [equals?])

Description
  • item-1 - first sequence

  • item-2 - second sequence

  • equals? - optional equality operator for items of sequence

Returns the optimal-string-alignment distance between the two given sequences, which is the number of substitutions/deletions/insertions/transpositions required to convert the first sequence into the second.

Error

If two given sequences:

  • are not string, list, vector or bytevector,

  • are different types, or

  • are different sizes.

[procedure] sorenson-dice-similarity
Definition

(sorenson-dice-similarity string-1 string-2 [n])

Description
  • string-1 - the first string

  • string-2 - the second string

  • n - optional n-gram size, defaults to 3

Returns the Sorenson Dice Index of the two given strings, when divided into n-grams.

[procedure] porter-stem
Definition

(porter-stem word)

Description
  • word - a string word, ASCII characters only.

Returns the given word reduced to its stem, following the Porter Stem algorithm: https://tartarus.org/martin/PorterStemmer/

[procedure] generate-password
Definition

(generate-password size [allow-duplicates? use-lowercase? use-numbers? use-symbols? use-uppercase?])

Description
  • size - length of password to generate

  • allow-duplicates? - flag to indicate if duplicates are permitted

  • use-lowercase? - flag to include lower case letters

  • use-numbers? - flag to include numbers

  • use-symbols? - flag to include symbols

  • use-uppercase? - flag to include upper case letters

Returns two values, a randomly generated password of required size and its entropy. If no options are indicated, then all character groups are included with duplicates permitted.

Error

If options prohibit construction of a password.