Skip to main content

Library for projecting memory kernels to experience functions

Project description

Kernel-Experience Tools 🧠 → ⏳

A Python library that turns memory kernels into experience functions.


📌 What is it?

Every memory kernel K(t) hides a story.

This library finds it.

Given the Volterra relaxation equation

x(t) = x₀ - ∫₀ᵗ K(t-τ) x(τ) dτ

we compute the unique experience function n(t) such that

x(t) = x₀ · λⁿ⁽ᵗ⁾

One kernel. One curve. One number.


🚀 Quick start

from kernel_experience import Kernel, project_kernel_to_n

# Pick a kernel
K = Kernel.tempered_power_law(alpha=0.6, beta=0.3)

# Get its experience function
t, x, n = project_kernel_to_n(K, t_max=10)

print(f"Memory score: {n[-1]:.2f}")
# Memory score: 3.44

📦 Installation

pip install kernel-experience-tools

📘 API Reference

Kernel

Container for your memory kernel.

Parameters

  • func: callable — Kernel function K(t)
  • name: str, optional — Kernel name (default: "CustomKernel")
  • params: dict, optional — Kernel parameters

Factory methods

# Exponential: γ·e^{-γt}
K = Kernel.exponential(gamma=1.0)

# Power law: γ·t^{α-1}/Γ(α)
K = Kernel.power_law(alpha=0.7, gamma=1.0)

# Mittag-Leffler: t^{α-1}E_{α,α}(-t^α)
K = Kernel.mittag_leffler(alpha=0.7)

# Tempered power law: γ·t^{α-1}e^{-βt}/Γ(α)
K = Kernel.tempered_power_law(alpha=0.6, beta=0.3, gamma=1.0)

Custom kernel

def my_kernel(t):
    return np.exp(-t) * np.cos(t)

K = Kernel(my_kernel, name="Oscillatory", params={"freq": 1.0})

project_kernel_to_n

Main projection: K(t) → n(t).

Parameters

Parameter Type Default Description
kernel Kernel Memory kernel
lambda_param float 0.8 Base λ in (0,1)
t_max float 10.0 Maximum time
n_points int 1000 Number of time points
x0 float 1.0 Initial condition
return_complex bool False Return complex n(t) for oscillatory kernels

Returns

Return Type Description
t ndarray Time grid
x ndarray Solution x(t)
n ndarray Experience function n(t)

Examples

# Basic usage
t, x, n = project_kernel_to_n(K, t_max=20, n_points=2000)

# Custom lambda
t, x, n = project_kernel_to_n(K, lambda_param=0.5)

# Oscillatory kernel — get complex n(t)
K_osc = Kernel(lambda t: np.exp(-0.1*t)*np.sin(t), name="Oscillatory")
t, x, n_complex = project_kernel_to_n(K_osc, return_complex=True)

# Extract real and imaginary parts
n_real = n_complex.real
n_imag = n_complex.imag

solve_volterra

Numerical solver for Volterra integral equation.

Parameters

Parameter Type Default Description
kernel Kernel Memory kernel
t_max float 10.0 Maximum time
n_points int 1000 Number of time points
x0 float 1.0 Initial condition

Returns

Return Type Description
t ndarray Time grid
x ndarray Solution x(t)

Example

t, x = solve_volterra(K, t_max=5, n_points=500)

compute_accuracy

Compare original and reconstructed solutions.

Parameters

Parameter Type Description
original_x ndarray Original solution x(t)
reconstructed_x ndarray Reconstructed solution x₀·λⁿ⁽ᵗ⁾

Returns

Return Type Description
dict dict Accuracy metrics

Metrics

  • mean_error: float — Mean relative error
  • max_error: float — Maximum relative error
  • accuracy: float — 1 - mean_error
  • rmse: float — Root mean square error

Example

# Get solution and n(t)
t, x, n = project_kernel_to_n(K)

# Reconstruct from n(t)
x_rec = 1.0 * (0.8 ** n)

# Check accuracy
metrics = compute_accuracy(x, x_rec)
print(f"Accuracy: {metrics['accuracy']:.2%}")
print(f"Mean error: {metrics['mean_error']:.2e}")
# Accuracy: 100.00%
# Mean error: 1.23e-12

🔄 Lambda conversion (0.2.0)

Experience values depend on your choice of λ. These tools let you convert between different scales — no need to pick a "right" one.

Methods (available directly from the Kernel class)

from kernel_experience import Kernel

# Convert experience from one λ to another
n2 = Kernel.convert_lambda(n=3.05, lambda_from=0.8, lambda_to=0.5)

# Get the conversion factor directly
factor = Kernel.scale_factor(0.8, 0.5)   # n₀.₅ = n₀.₈ * factor
Method What it does
convert_lambda(n, λ₁, λ₂) Returns n measured in scale λ₁ expressed in scale λ₂
scale_factor(λ₁, λ₂) Multiplication factor: n₂ = n₁ · factor

Formula

n₂ = n₁ · log_{λ₂}(λ₁)

Exact. No approximation. No privileged scale.

CHANGES IN VERSION 1.0.0


🚀 What's new in 1.0.0

10x faster C++ backend

  • Volterra solver now runs up to 10 times faster with optional C++ module
  • Automatically used if compiled, falls back to pure Python otherwise
  • No code changes needed — just pip install kernel-experience-tools

🔧 Seamless installation

  • C++ module compiles on‑the‑fly during pip install
  • Requires a C++ compiler (g++, clang, or MSVC) — automatically detected
  • Pure Python fallback ensures it always works, even without compilation

📦 Stable API

  • 100% backward compatible with 0.x versions
  • All existing code continues to work unchanged
  • Same functions, same parameters, same results — just faster

Production ready

  • First stable release
  • Extensively tested on 15+ kernel types
  • 100% accuracy on all physical kernels

📝 Пример для README.md

Example

You ran a kernel with λ = 0.8 and got n = 3.05.
What would that be if you had used λ = 0.5?

n_at_0_5 = Kernel.convert_lambda(3.05, 0.8, 0.5)
print(n_at_0_5)   # ≈ 2.07

Or get the factor once and reuse it:

factor = Kernel.scale_factor(0.8, 0.5)
n_at_0_5 = 3.05 * factor   # same result

🧠 What problem does it solve?

Traditional relaxation models assume exponential decay.

Real systems — glasses, polymers, biological tissues — show memory effects. Power laws. Stretched exponentials. Oscillations.

This library gives you one language for all of them:

K(t) → n(t)

Once you have n(t), the relaxation curve is simply x₀ · λⁿ⁽ᵗ⁾.

No fractional calculus. No special functions. No black boxes.

Just your kernel. One function call. One curve.


📄 Citation

@software{vozmishchev2026kernel,
  author = {Vozmishchev, Artem},
  title = {Kernel-Experience Tools: Projecting Memory Kernels to Experience Functions},
  year = {2026},
  doi = {10.5281/zenodo.18239294},
  url = {https://zenodo.org/records/18239294}
}

📜 License

MIT License


Now go find what your kernel remembers.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kernel_experience_tools-1.1.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kernel_experience_tools-1.1.3-cp312-cp312-win_amd64.whl (152.3 kB view details)

Uploaded CPython 3.12Windows x86-64

kernel_experience_tools-1.1.3-cp312-cp312-macosx_10_14_universal2.whl (264.3 kB view details)

Uploaded CPython 3.12macOS 10.14+ universal2 (ARM64, x86-64)

kernel_experience_tools-1.1.3-cp311-cp311-win_amd64.whl (150.3 kB view details)

Uploaded CPython 3.11Windows x86-64

kernel_experience_tools-1.1.3-cp311-cp311-macosx_10_14_universal2.whl (262.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ universal2 (ARM64, x86-64)

kernel_experience_tools-1.1.3-cp310-cp310-win_amd64.whl (148.6 kB view details)

Uploaded CPython 3.10Windows x86-64

kernel_experience_tools-1.1.3-cp310-cp310-macosx_10_14_universal2.whl (257.0 kB view details)

Uploaded CPython 3.10macOS 10.14+ universal2 (ARM64, x86-64)

File details

Details for the file kernel_experience_tools-1.1.3.tar.gz.

File metadata

  • Download URL: kernel_experience_tools-1.1.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for kernel_experience_tools-1.1.3.tar.gz
Algorithm Hash digest
SHA256 a2f7cd8c862439bd27a2c392bd88b97f3c40d7a6c94584fa685cd5dbc9395d13
MD5 0d17a1b05d1dd0b02f76bf3656a880ea
BLAKE2b-256 28d618b4de7e6d122a8e3c0eee3ce684fa3b70461558d7dba8cb9b3207d70035

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 71860b9736e378b4f01216ade81b33423a8b040c357b7053d48b870ded83b268
MD5 538c5c205cc1834329b3a6ea9442b5e2
BLAKE2b-256 c2f07c25b24120c0f361fa65e7499306e3de32d902af1b1b1929d932a4d790e7

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f37a0e12e0e6452db2b490e25c986f65cfe6523f18cf16185e17ea745b084105
MD5 7d1e2341a25b4c08f23cb1e1a75937d3
BLAKE2b-256 b806df6db7a62b0f287e68121614477b39da8c6a789270063e88bc0481f04442

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp312-cp312-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp312-cp312-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 76b28cb79f9df533085ef4c80bb947df1faf80ff344e86fcefa4e7a5e11a56fd
MD5 5382ae39041e555a3c0280a439c3fa0f
BLAKE2b-256 43dd65b877c75b4bda07b19c6ac7d1e49bfbc77c8518130ba1b7aeaf6e3876ff

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6e7a8a16cd32792d9c61b774a554f69c0b79abddafeb617a98f85fa0f02db7a7
MD5 c3bce7f239f132181bb2e812a46887ba
BLAKE2b-256 40b7b2b5585b3e137d62c7b0eea5821c5de88753d40f468b8562f2399d3b3c60

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e679c21b610490e2c56d2d0d131217500949ef60cbf8665d5708383580423d6e
MD5 be5f313af5285b28755699c3e7e82709
BLAKE2b-256 e56237702a64c158f4e19bbea6b9514e6d3a2c7a703ab2fe3ee8bae5b8e90bc0

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp311-cp311-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp311-cp311-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 73090b06a2dbb315b566e9a9c8ae5baeb26d44ecb468f230002b72b75812dcb0
MD5 071cf26b8c37a4924daaebb6105c0cc4
BLAKE2b-256 82168dc4e40a2e375b4c3f6bede0a492cbf885514f0280d613660b7db476ffd8

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 aca193a75b6047bab2b309ce97e677c52888df9a61304ae507f58d9d8412c91a
MD5 bb2cda7985c6684efc0930150a4f5586
BLAKE2b-256 d7850cf4c70a6ca9e9c31b73b7728e6a9660565c00428fd5050529ace86bd7cf

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b3a99b54453c9f99901622f967fd04c6af6924f6505fa1f1fceaf72d8a6ea71a
MD5 65a2b9ab321ac462c7fdf2587e54bd73
BLAKE2b-256 eb1ad1e9c558f11a6c53a3ab19ca9ba01c3425ae6eab7cb11c8a3c3fd867e3e1

See more details on using hashes here.

File details

Details for the file kernel_experience_tools-1.1.3-cp310-cp310-macosx_10_14_universal2.whl.

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.3-cp310-cp310-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 acffe12f25ebea6f2fbd9fea5530664be81e6e5aa5d6833eb6031533bcd36b05
MD5 88a1a1b1e035880c5732891069d960b0
BLAKE2b-256 e11cbfd971aa3a9a64459abb39bf284a6f184022ea2cd69f94d673c428701e03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page