Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sukhbinder/uqtoolkit
Simple Uncertainty Quantification Toolkit. Implements polynomial chaos.
https://github.com/sukhbinder/uqtoolkit
Last synced: 2 days ago
JSON representation
Simple Uncertainty Quantification Toolkit. Implements polynomial chaos.
- Host: GitHub
- URL: https://github.com/sukhbinder/uqtoolkit
- Owner: sukhbinder
- Created: 2017-04-09T10:21:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T18:07:26.000Z (about 7 years ago)
- Last Synced: 2024-11-21T23:53:22.641Z (2 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UQToolKit
Simple Uncertainty Quantification Toolkit implemented in pure python from a single file.Implements polynomial chaos.
## Sample usage
```python
import numpy as np
import matplotlib.pyplot as plt
from uqtoolkit import *# We will implement a simple model, which squares normally distrubuted random numbers
nsamples=5000
f=np.random.standard_normal(nsamples)
Y=f**2# Defining Polynomial Chaos (PC) exapansion
polyOrder=2 # Polynomial order
param = polyOrder+1
ndim=1 # No of random variables or dimensions
pc_type='HERMITE'# Create a PC object
pc=uq_pcset(polyOrder,ndim,pc_type)# Compute the quadtures
quadrature=uq_quadrature(ndim,param,pc_type)
# Evaluate quadrature at the PC
K=uq_getNISP(pc,quadrature)# Evaluate the model at the quadrature nodes
Ygrid=quadrature['nodes']**2# Project the response on the PC to compute PC coefs
c=np.dot(K,Ygrid)# Sample 5000 samples from the pc
U=uq_sample(pc,c,nsamples)# Mean and Std Dev of response
print 'Mean: ',Y.mean(),U.mean()
print 'St dev: ',Y.std(),U.std()print 'Mean ',c[0]
print 'stddev ',np.sqrt(c.sum())```