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.0.4.tar.gz (13.8 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.0.4-cp312-cp312-win_amd64.whl (81.2 kB view details)

Uploaded CPython 3.12Windows x86-64

kernel_experience_tools-1.0.4-cp312-cp312-macosx_10_14_universal2.whl (146.7 kB view details)

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

kernel_experience_tools-1.0.4-cp311-cp311-win_amd64.whl (80.3 kB view details)

Uploaded CPython 3.11Windows x86-64

kernel_experience_tools-1.0.4-cp311-cp311-macosx_10_14_universal2.whl (145.5 kB view details)

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

kernel_experience_tools-1.0.4-cp310-cp310-win_amd64.whl (79.3 kB view details)

Uploaded CPython 3.10Windows x86-64

kernel_experience_tools-1.0.4-cp310-cp310-macosx_10_14_universal2.whl (142.9 kB view details)

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

File details

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

File metadata

  • Download URL: kernel_experience_tools-1.0.4.tar.gz
  • Upload date:
  • Size: 13.8 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.0.4.tar.gz
Algorithm Hash digest
SHA256 39bc079c8d08a3a690956c3c4f1e43eb3b4dde5752b7ba955e3b46923108c0a1
MD5 739b393b245d6305958e53f4e3ee1fcd
BLAKE2b-256 bc11e001b6ed80d53ea64ec6410df86349a62427757f8fb2a23a6905abe68398

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ec6dcc375617bdebac35eea54f546c9f6423b9c7dfd0e0d64c2b14ef10fd753c
MD5 7c207f93ed9c2746bea0df04181c683d
BLAKE2b-256 a68b8e5f2b3ae9b62fce7c967b98b35377e818fb22a607656a35764754ebb96e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 172c7aa969037c49cba5686adacc8013e616c3fd826a67d06bdd29ea142062bc
MD5 1f4d4e54fde3166365714e7a976123f4
BLAKE2b-256 b7cee428b2616339cc276acf16b1140e8dcaf7cfdd6a686d3f9734ade0c2ee94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp312-cp312-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 09e15061578f6c43c3f8aea8b7007573f5bb1efbf3ecfaa58efceb64c06ae0d1
MD5 c8ef1c25404fa1c51490cc37276ea617
BLAKE2b-256 7e83c5063b35840f286487ff018f4a39ad762b225d1f21d8c14b0e1b07a87973

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8d5c0d5b2862d4ec94dc60fdcb988ed0ea2c073020f001755d8b2374bd97a790
MD5 044f11531937e907fbcd5b436d9a780f
BLAKE2b-256 0661c271483b15e607f43ef3fcd67c1a7b452e4b50535d70527a36391f75971e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abb4d71bdde05834c7911327b2fabe8d5f97703beaedd6fff0b70abefcb74d12
MD5 5782eba11035f5d628d5b7e43ba01453
BLAKE2b-256 94b9c5c12b0958e42b3fb8c9f1a8c0e0e0377f3d0a113e64ae1689ddebcc7424

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp311-cp311-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 3a41245509f1c2b7f22a15c2a417a0cd8c1f13c8ed384581b412c3d1dcfda4f4
MD5 bd287317629085c19eea386ee7a5419b
BLAKE2b-256 b942393b244de908e437fcca0569c737d8e52dc6624a2aeba40ce8b3b61270fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0acfe4f7f81e07ebdb4046ba3311435aeafdf7b922cc8aa5e884b7fb56ffa5c2
MD5 83a927dbcb911004418be73e33cb28a8
BLAKE2b-256 7a0c8944a20825cfe974fb0fe544c981a669619953cc09b9dc8992df36a97518

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 588ea0a95300c668ec99b2b8f7d6330869378fd572dc0704a549effa69c73d17
MD5 97f279cb2ecae999b89069de00d31d56
BLAKE2b-256 837d6bbf6a411d4e878475a9925dc1d36b67652670e7b14f7336dc79fd875841

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kernel_experience_tools-1.0.4-cp310-cp310-macosx_10_14_universal2.whl
Algorithm Hash digest
SHA256 e9ac168a5a48300c6bec8a00c5d284619b06601e6c9b5fe71050b89457bd2737
MD5 6b5521480fce0846fcc52c0d4e430488
BLAKE2b-256 080c64fc99e559e4e4915dfaf50060ebddaa77f3032324ada0d06c0ae2294235

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