Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Applications of Cognitive Theory in Data Modeling and Software Design

Written as both a refresher course on the mechanics of cognition in human psychology, and as the beginning of a working theory, wherein one might make some deductions from human psychology to broadly advance/improve the design of server software and data models for the industry en masse.

c. Mike McNeil, 2013-2014 All Rights Reserved.

What's the point of this? I think psychology will inevetiably instruct the future of software design, in the same way neurobiology is beginning to impact the hardware engineering industry.

Plus, at the end of the day, I find it very exciting to learn about :)


My particular interests lie in how this realm of psychological research applies to practical data modeling and server programming, with a focus on creating a better experience for developers, myself included. Therefore this document may be biased towards:

  1. how processes are encoded (e.g. how do I bake a cake? How do is that process stored and recalled? How do I know if someone else knows how to bake a cake?)
  2. concrete epistemology (e.g. What is (the|a) Chair? What is (the|a) Cindy? Who is (the|a) Cindy? Who is (the|a) Chair? Is Cindy (a|the) Chair? Is Cindy (a|the) Girl? Where is (the|a) Museum? How do I know what a Cindy is? Where did the symbol language for "Cindy" and "Chair" come from? How do we store and interpret data using indefinite vs. definite articles?).

And despite being very interested in them, I'm deliberately shirking any focus on the areas of motivation, creativity, attention, etc., in order to preserve my sanity. Especially any focus on lifting the veil of ignorance from algorithms. Especially that! Stop reading about that. Stop it.

Metaprogramming Perception Streams

Perception (from the Latin perceptio, percipio) is the organization, identification, and interpretation of sensory information in order to represent and understand the environment.

Perception impacts how stuff gets from the link layer of our input interface to our cognitive runtime.

(When I write "link layer", I mean our nervous system-- in other species like roundworms, sometimes this takes the form of simple action potentials, which are not all that dissimilar from memristors)

Perception is not the passive receipt of these signals, but is shaped by learning, memory, expectation, and attention.

Even the basic input systems of a human brain are colored by biases. i.e. here, we examine perception as an unscrupulous EventEmitter, but also as a bus that carries (and distorts) data on its way between other systems in our brains.

Perception is full of shifty little middlewares or stream transformers, some of which are very complex.

For each, there apears to be both a bottom-up (unconscious) and top-down (conscious) component:


  • deliberate recollection
  • both purposeful (memorization) and unintentional (remembering details of scary or emotional experiences)

untrainable by forget (unintentional) or supression (deliberate).

epistemic expectations
  • stereotypes
  • prejudices
  • heuristics
  • beliefs

untrainable by surprise (uninentional) or reasoning from first principles (deliberate)

  • focus

untrainable by overlook (unintentional) or ignore (deliberate)

"Perceptual learning"

The fact that with huge amounts of practice, individuals can reach impressive perceptual expertise, whether in wine tasting, fabric evaluation or musical preference, has been well acknowledged for centuries, along with the prevalent idiom that "practice makes perfect".

This seems to be the most basic form of perceptual optimization. This is not a proper term, but let's define and run w/ it, if we may.

Human examples:

  • learned reflex/intuition

    • extremely quick recall (caching)
    • indoctrination- negative perception at the name of a political enemy
    • getting really good at ducking if you get things thrown at you a lot
  • subjective discrimination

    • beer tastes nasty the first time
    • so do cilantro, mushrooms, cigarettes, cocaine, and black coffee
    • some people think toilet paper tastes good
    • you become conditioned to the sound of the TV in the background
    • you get used to loud music
    • etc.
  • subjective categorizations

  • objective discriminations

    • perfect pitch (is that a B flat??)
  • objective categorizations

    • identification (is that a tumor in that X-ray image??)

untrainable by more perceptual learning (uninentional) or deprogramming (deliberate)

A strong analogy exists in computing-- imagine a function getUserIdentity() whose purpose is to look at its arguments (information about an HTTP request) and determine if they can be used to pin an identity on the user who sent the request. Imagine that function being optimized based on traffic patterns. This could be accomplished through a mechanism where the users of getUserIdentity() award it "pats on the back" (analagous to dopamine hits in the human brain). If the caller is pleased, getUserIdentity() might follow certain heuristics to try to get more "praise".

// getUserIdentity.js
module.exports = function getUserIdentity(req, cb) {

  // Mix-in just a little randomness
  // Try to identify (perform script)
  var attemptedIdentification = eval(_script);
  cb(null, attemptedIdentification);
  // Save record of the arguments in closure scope:
  cb.on('reward', function () {
    // Apparently we did it right!
    var theRequestWeGotRight = req;
    var ourGuessThatWasRight = attemptedIdentification;
    // Optimize- rewrite _script for next time
    getUserIdentity._script = "...";

// Assign default behavior (i.e. our "genetics"):
getUserIdentity._script = getUserIdentity._script || (""+
	"for (var i=0; i<1000; i++) { " +
	"  var key = 'id'+Math.random();
	"  if (req.param(key)) return req.param(key);" +
// caller.js

// Let's use `getUserIdentity`
var getUserIdentity = require('getUserIdentity');

// our callback will also be an event-emitter
// (so getUserIdentity knows which `run` of itself it's being rewarded for)
var cb = function (err, result) {
  if (err) return res.serverError(err);
  // Save the `cb` and result
  // so we can use it to identify and reward the function later.
  req.session.memories.getUserIdentity = { fn: cb, result: result };
  // Done for now
getUserIdentity(req, cb);
// ...
// Down the line (could be days/weeks later)
// maybe we get more data and find out who this user is definitively.
// (or maybe we just ask them if we got their identity right and they confirm.)
// So we need to check to if our function guessed right, and reward it accordingly if it did:

// Turns out this user has an id of 235
  success: function (user) {
    var correctGuesses = _.where(req.session.memories.getUserIdentity, {result:});
    _.each(correctGuesses, function (guess) {

A more practical javascript example might be a duck-typing algorithm that is rewarded based on a combination of reduced time-to-completion and accuracy. It'll be optimized only for a certain traffic pattern, but would be handy for identifying, say, a User, based on its attributes. Or even identifying a particular user based on their attributes and relations to other entities in the data graph.


One hypothesis in the scientific community seems to be that on-demand perception/understanding in humans is roughly analogous to a complex algorithm.

We'll go with that. So how is this algorithm programmed?

Back to the same duality-- it seems to be partially composed of predispositions (bottom-up) and purposeful decisions (top-down). Bottom-up cognition can be exogenous (external stimuli) or not, but top-down cognition always comes from within (self-determination). This is not an argument against determinism-- both types of cognition are influenced by external factors-- it's just that top-down cognition does provide a moment of free will, albeit with a finite set of possibilities (i.e. limited to creativity)

One might say perception is trained on the following corpora:

  1. biology/instinct/emotions (humans are good with faces, what I can say?)
  2. genetics/womb-factors (I'm horrible with directions)
  3. conditioning (+ any moral/ethical reasoning <= kohlberg stage 4)
  • based on familial factors such as upbringing/parenting style
  • but also social coincidence, bullying, etc.
  1. deliberate recollection of past experiences
  2. purposeful memorization
  3. and at the highest level, abstract planning, hypothetical thinking- which is actually more complex, and has its own echelons to explore, I think, but not now.

(Also see Constancy, Gestalt Grouping, and Contrast Effects.)

The Cognitive Runtime

"Only small parts of the brain resemble a tabula rasa; this is true even for human beings. The remainder is more like an exposed negative waiting to be dipped into a developer fluid"

~ Wilson, E. O., Sociobiology: The New Synthesis.

In other words, don't check whether it IS-a duck: check whether it QUACKS-like-a duck, WALKS-like-a duck, etc, etc, depending > on exactly what subset of duck-like behaviour you need to play your language-games with.

~ Alex Martelli, 2000 (comp.lang.python newsgroup)

TODO: come back to this


This comment has been minimized.


This comment has been minimized.

Copy link
Owner Author

@mikermcneil mikermcneil commented Jan 12, 2014

I got it a little off, in retrospect-- the perceptual "transformers" are actually all implicit (bottom-up) for our purposes.

The top-down perception influencers are part of a different mechanism, I think, let's call it metaprogramming, e.g.:

learning mnemonics, choosing to pay attention to something, deliberately surrounding yourself with a certain type of persons, purposefully rewarding yourself with candy for doing your homework

That's what I plan to write about in the third section- ie if you wanted to create a new form of life, you would need to design not only reward/punishment rulesets (ie. "MMM, FOOD, DOPAMINE, SEX. ME LIKE") but also a suite of strategies for modifying perception and, even more exciting, cognition.


This comment has been minimized.

Copy link
Owner Author

@mikermcneil mikermcneil commented Jan 12, 2014

Also see the "pocket algorithm":


This comment has been minimized.

Copy link
Owner Author

@mikermcneil mikermcneil commented Jan 12, 2014

Re duck typing, see "confusion tables":


This comment has been minimized.

Copy link

@thebigredgeek thebigredgeek commented Feb 15, 2014

Very interesting. I'd be really interested in pursuing a project like this with you Mike. Data Science and Machine Learning are my areas of interest.


This comment has been minimized.

Copy link

@EUPRAXIA1 EUPRAXIA1 commented Jul 29, 2014

I have only skimmed what you've written here (so far) but you might want to read 'How to Create a Mind' by Ray Kurzweil. Human minds are pattern recognition engines. And we have managed to do great things with that ability.


This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment