Ir al contenido

Functions and Numeric Results

Esta página aún no está disponible en tu idioma.

A numeric query reduces a collection, combines scalar values, or calculates a value within the current item. The formula determines what the final number means.

To total key-to-key travel across the corpus, sum weighted distance with map(...).sum after projecting pairs with kp:

bi.kp.map(d).sum

Weighting and aggregation#

count is an unweighted count of selected rows or projected pairs. freq divides selected occurrence mass by the complete source population of the same width.

map(expression).sum evaluates the expression for each retained item and applies that item’s occurrence weight once. Pairs projected from a report collection retain the source window weight. Pairs made inside an outer window map have unit local weight before the outer map applies its weight.

at(index) reads one number from a mapped numeric collection using a zero-based index; an index beyond the end produces nil. slice(start,end) keeps a range from the zero-based start through the exclusive end. Slice bounds beyond the collection are clamped, and an equal start and end produces an empty collection. Indices must be finite nonnegative integers, and a slice start cannot exceed its end.

corpus.graphemes records the output grapheme count of the corpus for provenance and explicit arithmetic in authored formulas. It does not supply the denominator of freq, which retains the original weighted source-window population.

A pair can occur many times but occupy a single report row. Compare .count for matching report rows with .freq for their weighted occurrences. Both start with the sfdk filter:

bi.sfdk.count
bi.sfdk.freq

Numeric collections and reducers#

Count#

collection.count

Counts selected rows or projected physical action pairs without weighting.

bi.sf.count

Frequency#

collection.freq

Divides selected occurrence mass by the complete source population of the same width.

bi.sf.freq

Mapped sum#

collection.map(number).sum

Evaluates a scalar for every selected weighted item and sums each mapped value times its occurrence weight.

bi.sf.map(1).sum

Occurrence weight#

weight

The exact retained occurrence weight of the current mapped item; mapped sums also apply this weight implicitly.

bi.sf.map(weight).sum

Oxeylyzer finger speed#

fspeed_oxeylyzer(r:, lp:, lr:, lm:, li:, lt:, rt:, ri:, rm:, rr:, rp:)

Scores same-finger movement using Oxeylyzer’s defaults. More negative values mean more weighted movement. Includes presses, hold starts and releases, but not keys that stay held. Uses strike-point distance for wide keys and averages same-finger keys in a chord. Requires bigrams through quintgrams; returns nil if there are no bigrams. Finger strengths are positive numbers, ordered pinky through thumb on each hand by symmetry: 1.4, 3.6, 4.8, 5.5, 3.3.

Aliases: fsoxey.

fspeed_oxeylyzer()
fsoxey(r:0.2, li:5.5)

Oxeylyzer finger speed: Decay#

r

Weight multiplier per intervening keystroke, from 0 to 1. Defaults to 1/7.

Number at index#

numbers.at(index)

Returns the number at a zero-based index, or nil when the index is beyond the collection.

bi.map(weight).at(0)

Number at index: Index#

index

A finite nonnegative integer index.

Number range#

numbers.slice(start,end)

Keeps a zero-based range of numbers through an exclusive end, clamping bounds to the collection length.

bi.map(weight).slice(0,10).sum

Number range: Start#

start

The finite nonnegative integer start index.

Number range: End#

end

The finite nonnegative integer exclusive end index.

Use multiplication by 100 to express a frequency as a percentage. Arithmetic on distances uses the key-unit numbers returned by geometry properties.

bi.sfdk.freq * 100

Numeric operators and values#

Arithmetic#

number + number

Bounded finite arithmetic; exponentiation binds before unary minus and associates to the right.

100 * bi.sf.map(1).sum / corpus.graphemes

distance#

distance

Euclidean physical key distance in key units.

Aliases: d.

bi.kp.map(d ^ 2).sum

dx#

dx

Signed horizontal physical displacement in key units.

bi.kp.map(dx).sum

dy#

dy

Signed vertical physical displacement in key units.

bi.kp.map(dy).sum

hd#

hd

Euclidean distance from the effective finger's home to this key, in key units. Alternate fingering selects the effective finger; a used finger without a home is rejected at binding.

Aliases: home_distance.

uni.map(first.keys(events:press).map(hd).sum).sum

hdx#

hdx

Signed horizontal displacement from the effective finger's home to this key, in key units. Positive points right. Alternate fingering selects the effective finger.

Aliases: home_dx.

uni.map(first.keys(events:press).map(hdx).sum).sum

hdy#

hdy

Signed vertical displacement from the effective finger's home to this key, in key units. Positive points down. Alternate fingering selects the effective finger.

Aliases: home_dy.

uni.map(first.keys(events:press).map(hdy).sum).sum

Horizontal coordinate#

point.x

The point's x coordinate in key units, or nil if absent.

uni.map(first.fpos(finger:LI).x).compact.sum

Vertical coordinate#

point.y

The point's y coordinate in key units, or nil if absent.

uni.map(first.fpos(finger:LI).y).compact.sum

When a pair has no defined stretch, an average can omit the pair or include it with a value of zero. Discard undefined stretch values with compact, or replace them explicitly with ??. Both examples map the signed stretch. These choices affect an average’s denominator differently.

bi.kp.map(s).compact.sum
bi.kp.map(s ?? 0).sum

Missing numeric values#

nil represents an absent numeric or Boolean value. The ?? operator evaluates its right side only when the left side is nil. compact removes only nil values from a mapped numeric collection; it does not remove zero or false.

Arithmetic and ordered comparisons involving nil remain nil. false & nil is false, true | nil is true, and other Boolean combinations preserve the unknown result. nil equals nil and differs from present values. A mapped sum is nil when an unhandled nil remains; use ?? for a fallback or compact to omit absent items.

bi.kp.map(s ?? 0).sum
bi.kp.map(s).compact.sum

Missing results#

Present values#

numbers.compact

Drops only nil values from a mapped numeric collection.

bi.kp.map(s).compact.sum

Absent value#

nil

An explicitly absent numeric or boolean value.

bi.kp.map(s ?? 0).sum

Fallback#

value ?? fallback

Evaluates the right operand only if the left is nil.

bi.kp.map(s ?? 0).sum

To compare occurrences per analyzed character across corpora of different lengths, use corpus.graphemes as an explicit denominator when your metric describes an amount per analyzed character. The annotated corpus.written_graphemes total is separate and can be absent.

bi.sfdk.map(1).sum / corpus.graphemes

Corpus counts#

Corpus graphemes#

corpus.graphemes

The total grapheme count in the corpus, available as an explicit denominator for custom formulas. It is separate from freq: an n-gram freq divides by the weighted source population for that same width.

100 * bi.sf.map(1).sum / corpus.graphemes

Written graphemes#

corpus.written_graphemes

The weighted written-text grapheme count supplied by the corpus projection.

100 * uni.count / corpus.written_graphemes