Add the non-kernel functions: Sigmoid, Average, VectorLength (#321) - #961
Merged
Conversation
Functions worth being able to write, which need no node of their own because the
kernel can already say what they mean:
Sigmoid(x) 1 / (1 + e ^ (-x))
Average(m) the sum of a matrix's cells over their count
VectorLength(v) Abs of the vector
The last is a name rather than a capability: abs([3, 4]) has always answered 5, which
is what @WhiteBlackGoose observed on the issue -- "VectorLength is Abs" is the whole
implementation. It is here so the operation can be found by the name a caller looks
for, and a test requires the two to agree so they cannot drift into two definitions.
Being ordinary expressions is the point rather than an implementation detail, and the
tests are written to show it: nothing here teaches the library to differentiate a
sigmoid or take its limit, and both work --
d/dx Sigmoid(x) e ^ (-x) / (e ^ (-x) + 1) ^ 2
at +oo 1
at -oo 0
A node instead would mean the eleven steps of Docs/Contributing/AddingNode.cs and a
new shape for every rule to ignore, for no reach these do not already have.
Average is symbolic: of [a, b] it is (a + b) / 2, not a refusal.
Taylor, the fourth item on the issue, was already implemented and ticked. Max, Min and
Mean are struck through there. Mode and median are a separate question -- they are not
expressible this way, which is why @Happypig375 and @WhiteBlackGoose disagreed about
them, and this does not settle it.
Purely additive: no answer changes, so no BREAKING-CHANGES entry. Suite 7274 passed,
0 failed. PublicApi.txt regenerated, three members added and nothing else moved.
This was referenced Aug 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #321.
Three functions worth being able to write, which need no node of their own because the kernel can already say what they mean:
Sigmoid(x)1 / (1 + e ^ (-x))Average(m)VectorLength(v)Absof the vectorVectorLengthis a name, not a capabilityabs([3, 4])has always answered5— which is exactly @WhiteBlackGoose's observation on the issue:So it is here so the operation can be found under the name a caller reaches for, and a test requires the two to agree, so they cannot drift into two definitions of one thing.
Being an ordinary expression is the point
Nothing in this PR teaches the library to differentiate a sigmoid or take its limit. Both work anyway, and the tests are written to show that rather than to check one-line formulas:
Adding a node instead would mean the eleven steps of
Docs/Contributing/AddingNode.csand a new shape for every rule to ignore, for no reach these do not already have. That is what "non-kernel" buys.Averageis symbolic: of[a, b]it is(a + b) / 2rather than a refusal.Scope, against the issue's checklist
Evidence
VectorLengthandAbsagree, thatAveragereads every cell of a 2×2 matrix, and that null is refused rather than dereferencedPublicApi.txtregenerated: three members added, nothing else movedBREAKING-CHANGES.mdentry🤖 Generated with Claude Code