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.1.tar.gz (15.4 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.1-cp312-cp312-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12Windows x86-64

kernel_experience_tools-1.1.1-cp312-cp312-macosx_10_14_universal2.whl (306.4 kB view details)

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

kernel_experience_tools-1.1.1-cp311-cp311-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.11Windows x86-64

kernel_experience_tools-1.1.1-cp311-cp311-macosx_10_14_universal2.whl (302.8 kB view details)

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

kernel_experience_tools-1.1.1-cp310-cp310-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.10Windows x86-64

kernel_experience_tools-1.1.1-cp310-cp310-macosx_10_14_universal2.whl (297.2 kB view details)

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

File details

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

File metadata

  • Download URL: kernel_experience_tools-1.1.1.tar.gz
  • Upload date:
  • Size: 15.4 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.1.tar.gz
Algorithm Hash digest
SHA256 c7fbb3123a6fc76a9f4079aae50a6a5ccafe1ca535899702df545e5fa48d7854
MD5 b7bcdd571d264b446aa4a4b80b5fa4e4
BLAKE2b-256 b2fd1cc3be88eb1fa2b41861414effd250c508c31c5781ed0292cb5d6c012757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3c50d2b84dc7504fc1f277ffb43a25270c9a2cfc055c2a4d8800dd7be0d449d3
MD5 4931d392dcc0e60fe7e6281d61cd59cc
BLAKE2b-256 e19da1e44d70f09d20357da6ed32439f254e0e2f1d9f87e841c95fd563a16585

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1da690159aa384e0e04655b3cca2c4bf8e5c6fc788ca152d25e6b3443a1882ad
MD5 4dc68572e8a669ba9c76a3ac4335c15b
BLAKE2b-256 636ae73df3148299bb35416bc770208898fd03b3879dc335346fee45897f7290

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp312-cp312-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 90e840fd9fe401bb05634d786708cba13f89ae36b0a7442f047322e99759f854
MD5 31778b7873ecb743bcb390ff38b78ace
BLAKE2b-256 8b5b0158c558c9feb8b082807be5bd419101230664ff616e36b6d75b1442a9e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d83fe6cba46f1d9d46f7e2db3a54c117743929f7de5aa4626ec0a974c91a3943
MD5 b298bf4683dd2559c313c7b52e2445cb
BLAKE2b-256 6d37505ba77647564e451f14a565cc469e1972d747d769df65e5a2b4053d8df7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 643d831ac141c55fab35c2c1dd0e217373e1fdc4f5914ccc6c1c626e4df557f1
MD5 8dd43a279f2227369ede223b8a0de38c
BLAKE2b-256 8dd64ae381296ae8c114ec50f781ad8965674923642932f5fc0f19631694d316

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp311-cp311-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 be2b368717b8678cd9bdab6745b5f9c7784f3982c886ae19c8a0cf02a5c293be
MD5 3ef16d3cad200421c84df38441ce13d6
BLAKE2b-256 47f3f5a3f0b8a8af906eba3e44a9495ae39b6b1d3abc7775b055c75e5a1d5486

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 494447b893b786d4866fd968edd1f965b6b5085e50706184a13cb067b3e95822
MD5 37c749f4208f095a240d33610010baed
BLAKE2b-256 ce9544db32abf94c2f00d073fcf866be192217982106996bbe989ef3bcb83d95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c85f38cbadd1311abd4b5df9966d3458cad64a7ba091504c0debf5469828dfb
MD5 fab1df20c9e94e9af270d2701289df78
BLAKE2b-256 c94267fe6eed89af64253e53e9a6a991458e4d96b359d537eb1c98907029443e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.1.1-cp310-cp310-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 269d3f8ea4c43a45272ff47885a7f0ecb23195a51d9dc7a7ca730a4c1babbef2
MD5 5d3e019eaa89c7a7d943ef407e9a8550
BLAKE2b-256 1eb2acace35c969d4722b047192d2f3f0c8a880c2680888177f24ce6a1016d42

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