Posts for the month of March 2013

python-randomfields: a Python module for identifying non-stationary non-Gaussian random fields

Hi all,

On the occasion of the Material Ageing Institute Scientific Network (MAI-SN) partnership (initiated by EdF, TEPCO and EPRI), Phimeca Engineering, EdF R&D and Institut Navier (ENPC) implemented a prototype Python module for the simulation and the identification of non-stationary non-Gaussian random fields based on the Karhunen-Loève expansion representation. Provided some suitable measurements are made this could help modelling the randomness in the material properties of ageing structures.

It is our pleasure to announce this module is available for using and contributing. In this respect, a dedicated github repos has been created:

https://github.com/dubourg/python-randomfields

Please feel free to fork it or simply clone/download the code.

The main page of the repos displays a README file whose reading is highly recommended. It also features a non-exhaustive todo list. Contributions are welcome!

The module is essentialy based on Numpy and the ever-improving Python bindings to OpenTURNS (Thanks J!). It implements a single object named KarhunenLoeveExpansion which is self-documented using python dosctrings. The object discretizes the random field at instanciation by solving the Fredholm integral equation using a Legendre-Galerkin scheme. Integrals are numerically approximated using Gauss-Legendre quadrature (from OpenTURNS). Other Galerkin schemes could possibly be used (eg. wavelet-based Galerkin schemes) but the Legendre scheme is the only scheme implemented yet. The instanciated object is callable and takes the field index vector (eg space, time, potatoes, ...) and the seed as input. See the references in the README file if this already sounds like gibberish to you!

The repos contains 4 scripts in addition to the module for illustrating how the KLE object can be used for simulation and identification. Regarding identification, once the sample paths have been transformed into a sample of coefficients vector, we are back into basic statistics! Hence, OpenTURNS can be used for identifying the joint distribution of this coefficients vector. Karhunen-Loève theory states they are zero-mean, unit-variance and uncorrelated (by construction) but their joint distribution is generally unknown if the field is not assumed to be Gaussian. Identifying such large vectors is still a technically (if not scientifically) openned question though so...

Enjoy and give us feedback!

Marine Marcilhac & Vincent Dubourg

PS: Thank Marc Berveiller and Géraud Blatman at EdF for the very first feedback which helped reaching this first public version.

Easy fitting using OpenTURNS

The development of python functionalities to easily fit statistical univariate distributions from 1D samples is proposed.

These functionalities are available through two subpackages:

  • FitContinuousDistribution1D: fitting tests for continuous distributions.
  • FitDiscreteDistribution1D: fitting tests for discrete distributions

In the two cases, the sample is tested using a catalog of all distribution factories implemented in the OpenTURNS library. The fitting object result gives access to several services:

  • Get the list of all distributions for which the test has been done, sorted according to BIC or Kolmogorov criterion.
  • Get the list of all distributions for which the test has been accepted according to the Kolmogorov criterion.

This list is sorted according to BIC or Kolmogorov criterion;

  • Get the list of distributions for which the test could not be done and the reason.
  • Pretty print (Tested distributions, accepted distributions, not tested distributions).

Here is an example of use :

import openturns as ot
from easyfitting import FitContinuousDistribution1D
# Continuous case
x = ot.Normal(0, 1).getSample(20)
pvalue = 0.10
fitting = FitContinuousDistribution1D(x, pvalue)
# Print all distributions tested and ranked according to BIC criterion
fitting.printTestedDistribution('BIC')
# Get this list
all_distributions_tested = fitting.getTestedDistribution()
# Print all distributions accepted and ranked according to KS criterion
fitting.printAcceptedDistribution('KS')
# Get this list
all_distributions_accepted = fitting.getAcceptedDistribution('KS')
# Print distributions that could not be tested and the reason
fitting.printExceptedDistribution()

The sources could be downloaded here

We welcome any comments.

Regards,

Denis
Sofiane

ps: For the discrete case, current OpenTURNS version is limited. Indeed, the library has not been updated due to recent changes in rot package. Thus only Poisson and Geometric distributions have correctly been tested.