npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cobb-douglas-neuron

v1.0.0

Published

Experimental comparison of a classical (degree-0) neuron against a degree-(+1) Cobb-Douglas neuron, derived from the logarithmic-exponential conjugation principle.

Downloads

136

Readme

cobb-douglas-neuron

npm version License: MIT TypeScript

An experimental comparison of a classical (degree-0) neuron against a degree-(+1) Cobb-Douglas neuron, derived from the logarithmic-exponential conjugation principle.

This repository is the sibling of conjugate-neuron. Where conjugate-neuron explored the degree (-1) displacement (LogSumExp / microstate neuron), this repo explores the degree (+1) displacement — the Cobb-Douglas neuron.


The mathematical core

The conjugation principle defines an infinite hierarchy of binary operations *_k:

a *_k+1 b = exp( log(a) *_k log(b) )

Setting *_0 = + gives:

| Degree | Operation | Closed form | |--------|-----------|-------------| | -1 | *_{-1} | log(e^a + e^b) (LogSumExp) | | 0 | + | a + b (addition) | | 1 | × | a · b (multiplication) | | 2 | *_2 | exp(log a · log b) = a^{log b} (new operation) |

The Cobb-Douglas neuron (degree +1)

A classical neuron uses × (degree 1) to combine weights and inputs, and + (degree 0) to aggregate:

z = Σ_i w_i · x_i + b

A degree-(+1) neuron displaces both operations up one level: combination becomes *_2 (degree 2), aggregation becomes × (degree 1):

z = b · ∏_i (w_i *_2 x_i)
  = b · ∏_i exp(log w_i · log x_i)
  = b · ∏_i x_i^{log w_i}

This is the Cobb-Douglas production function from economics (Cobb & Douglas, 1928), where log(w_i) plays the role of elasticities. The neuron is mathematically equivalent to a classical neuron operating on log-features, but with multiplicative backpropagation — the gradient scales with the output z.


What the experiment tests

For each dataset, the runner trains two single neurons under identical conditions:

| | Classical neuron (degree 0) | Cobb-Douglas neuron (degree +1) | |---|---|---| | Pre-activation | z = Σ wᵢxᵢ + b | z = b · ∏ xᵢ^{log wᵢ} | | Combination op | × | *_2 = a^{log b} | | Aggregation op | Σ | (product) | | Gradient dynamics | Additive (independent of z) | Multiplicative (scales with z) | | Positivity constraint | None | Weights and inputs must be > 0 | | Natural domain | Linear/additive data | Multiplicative/power-law data |

Both share the same optimizer, learning rate, seed, and epoch budget. The only independent variable is the arithmetic.


Datasets

| Dataset | Structure | Expected winner | |---------|-----------|-----------------| | Cobb-Douglas | y = ∏ xᵢ^{αᵢ} (multiplicative) | Cobb-Douglas neuron | | Power law | y = x^α (single input) | Cobb-Douglas neuron | | Log-normal mixtures | Multiplicative analog of Gaussian mixtures | Cobb-Douglas (by structure) | | Linear | y = Σ wᵢxᵢ + b (additive) | Classical neuron | | XOR | Additive boolean (shifted to positive) | Neither (single-neuron ceiling) |


Quick start

git clone https://github.com/Justo-Tapiador/cobb-douglas-neuron.git
cd cobb-douglas-neuron
npm install
npm start
# → open http://localhost:3000

Or headless:

npm start -- --headless --dataset cobb-douglas --epochs 300 --lr 0.05

Key experimental results

Preliminary results (single neuron, Adam, 300 epochs, lr=0.05):

| Dataset | Classical loss | Cobb-Douglas loss | Winner | |---------|---------------|-------------------|--------| | Cobb-Douglas regression | 0.0154 | 0.0050 | Cobb-Douglas (3× lower loss) | | Power law y=x² | 0.414 | 0.041 | Cobb-Douglas (10× lower loss) | | Linear regression | 0.0062 | 0.134 | Classical (20× lower loss) | | Log-normal mixtures | 0.755 | 0.655 | Cobb-Douglas (lower loss) | | XOR | 0.693 | 0.520 | Both plateau at 50% acc |

Headline finding: the Cobb-Douglas neuron wins decisively on multiplicative data (3-10× lower loss) and loses decisively on additive data (20× higher loss). This confirms the hypothesis that the conjugation hierarchy provides arithmetics specialized to different data structures.

On Cobb-Douglas regression, the neuron recovers the true elasticities α_i as log(effective_w_i) — e.g. true [0.5, 0.3, 0.2] → recovered [0.52, 0.25, 0.25].


Repository structure

cobb-douglas-neuron/
├── src/
│   ├── arithmetic/
│   │   ├── Arithmetic.ts           ← the interface
│   │   ├── ClassicalArithmetic.ts  ← degree 0: ×, +
│   │   ├── CobbDouglasArithmetic.ts ← degree +1: *_2, × (with softplus weights)
│   │   └── index.ts
│   ├── tensor/                     ← Vector, Matrix, RNG
│   ├── nn/                         ← Parameter, Neuron (softplus), Layer, Network
│   ├── activations/                ← Identity, Sigmoid, Tanh, ReLU
│   ├── losses/                     ← MSE, BCE, CrossEntropy
│   ├── optimizers/                 ← SGD, Adam
│   ├── datasets/                   ← Cobb-Douglas, power-law, log-normal, XOR, linear
│   ├── experiments/                ← ExperimentRunner, runComparison
│   ├── server/                     ← Express + WebSocket dashboard
│   │   └── public/                 ← HTML/CSS/JS with Chart.js
│   ├── main.ts                     ← CLI entry point
│   └── index.ts                    ← public library entry point
├── tests/
│   └── arithmetic.test.ts          ← 10 unit tests
└── docs/
    └── theory.md                   ← mathematical background

License

MIT — see LICENSE.

Related work

  • conjugate-neuron — the sibling repo exploring degree (-1) (LogSumExp / microstate neuron)
  • The conjugation principle papers (J. Tapiador García) — see docs/theory.md