background preloader

Python

Facebook Twitter

9.6. random — Generate pseudo-random numbers. Source code: Lib/random.py This module implements pseudo-random number generators for various distributions.

9.6. random — Generate pseudo-random numbers

For integers, uniform selection from a range. For sequences, uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without replacement. On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating distributions of angles, the von Mises distribution is available. Almost all module functions depend on the basic function random(), which generates a random float uniformly in the semi-open range [0.0, 1.0). The functions supplied by this module are actually bound methods of a hidden instance of the random.Random class. New in version 2.4: the getrandbits() method. As an example of subclassing, the random module provides the WichmannHill class that implements an alternative generator in pure Python.

Warning. 17.1. subprocess — Subprocess management. Execute a child program in a new process.

17.1. subprocess — Subprocess management

On Unix, the class uses os.execvp()-like behavior to execute the child program. On Windows, the class uses the Windows CreateProcess() function. The arguments to Popen are as follows. args should be a sequence of program arguments or else a single string. By default, the program to execute is the first item in args if args is a sequence.

Scipy.stats.linregress — SciPy v0.14.0 Reference Guide. Exécuter un .exe avec des paramètres à partir d'un script python. Scipy.interpolate.UnivariateSpline — SciPy v0.15.1 Reference Guide. Interpolation (scipy.interpolate) There are several general interpolation facilities available in SciPy, for data in 1, 2, and higher dimensions: Multivariate data interpolation (griddata) Suppose you have multidimensional data, for instance for an underlying function f(x, y) you only know the values at points (x[i], y[i]) that do not form a regular grid.

Interpolation (scipy.interpolate)

Suppose we want to interpolate the 2-D function >>> def func(x, y):>>> return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2 on a grid in [0, 1]x[0, 1] >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j] but we only know its values at 1000 data points: >>> points = np.random.rand(1000, 2)>>> values = func(points[:,0], points[:,1]) This can be done with griddata – below we try out all of the interpolation methods: 2. Built-in Functions — Python 2.7.10rc0 documentation.

Open a file, returning an object of the file type described in section File Objects.

2. Built-in Functions — Python 2.7.10rc0 documentation

If the file cannot be opened, IOError is raised. When opening a file, it’s preferable to use open() instead of invoking the file constructor directly. The first two arguments are the same as for stdio‘s fopen(): name is the file name to be opened, and mode is a string indicating how the file is to be opened.

The most commonly-used values of mode are 'r' for reading, 'w' for writing (truncating the file if it already exists), and 'a' for appending (which on some Unix systems means that all writes append to the end of the file regardless of the current seek position). If mode is omitted, it defaults to 'r'. The optional buffering argument specifies the file’s desired buffer size: 0 means unbuffered, 1 means line buffered, any other positive value means use a buffer of (approximately) that size (in bytes).

In addition to the standard fopen() values mode may be 'U' or 'rU'.

Liste et tableaux

Traitement du signal. Algorithmique. Graphes - Matplotlib. Lire -écrire dans un fichier texte. Chaines de caractère.