Numerical experiments in python
Project description
exppy - module that automates numerical experiments
This module is intended for performing numerical experiments with continuous parameters. Currently, parameters of the model can be randomized with uniform or log-uniform distributions in the given range. Simple random, latin hypercube or generalized subset designs can be used (supported by pyDOE2
package).
Example:
from exppy import LHSDesign, Experiment
from math import sin, cos
import pylab
class MyDesign(LHSDesign):
spec = (('x', (0, 6.28, 'uniform', 10)),
('y', (0, 6.28, 'uniform', 10)))
samples = 50
class MyModel:
# model can be any class, but it is required to have 'solve' method
# which takes sample `d` as argument and returns dict of results `res`
def solve(self, d):
x, y = d.x, d.y
res = {'F': sin(x)*cos(y), 'G': x*y}
return res
# Evaluate experiments and dump everything to 'test' directory:
ex = Experiment(MyDesign(), MyModel(), dirname='test')
ex.run()
# Plot 'F'
x = ex.design.x
y = ex.design.y
F = ex.result.F
pylab.tricontour(x, y, F, levels=14, linewidths=0.5, colors='k')
cntr = pylab.tricontourf(x, y, F, levels=14, cmap="RdBu_r")
pylab.colorbar(cntr)
pylab.plot(x, y, 'ko', ms=3)
pylab.title('$\sin(x)\cos(y)$\n (%d LHS samples)' % ex.design.samples)
The resulting figure looks like this:
For more hints look into the test_exppy.py
file. Docs are in plans...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
exppy-0.1.3.tar.gz
(7.3 kB
view details)
Built Distribution
exppy-0.1.3-py3-none-any.whl
(7.3 kB
view details)
File details
Details for the file exppy-0.1.3.tar.gz
.
File metadata
- Download URL: exppy-0.1.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f5628e816619d3a6e046bcc7143861aeddc462f1c7f022dd9fe914a620b73e6 |
|
MD5 | af29323ae87fff1209e2d64235ddba4d |
|
BLAKE2b-256 | 551ea272f4218fb15ff5e3046446e882eb7a58f89992b8a19ca3f11cf7b5beaa |
File details
Details for the file exppy-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: exppy-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3de7dc154dc510b2568f43f02eba5b4366347b2aadf66358c8c5026510005cd8 |
|
MD5 | 4b8b9a44f4e115cf286321620a65ef7a |
|
BLAKE2b-256 | 6b88d7848f2997732f0256e8a35d1d8eb42608cd8a5a48bfa6a568a860c01b6b |