Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2"""
3@file
4@brief Jeux de données artificiels.
5"""
6from numpy.random import rand, randn
7from numpy import vstack
10def line2d(n, x0=0, x1=10, a=0.5, b=1, sigma=0.5):
11 """
12 Simule un jeu de données pour une régression linéaire.
13 Notebooks associés à ce jeu de données :
15 .. runpython::
16 :rst:
18 from papierstat.datasets.documentation import list_notebooks_rst_links
19 links = list_notebooks_rst_links('lectures', 'artificiel_shape')
20 links = [' * %s' % s for s in links]
21 print('\\n'.join(links))
23 @param n nombre de points à simuler
24 @param x0 dans l'intervalle *[x0, x1]*
25 @param x1 dans l'intervalle *[x0, x1]*
26 @param a *a*, voir ci-dessous
27 @param b *b*, voir ci-dessous
28 @param sigma écart type du bruit blanc
29 @return une matrice
31 La régression linéaire suit le modèle
32 :math:`y = ax + b + \\epsilon`.
33 """
34 x = rand(n) * (x1 - x0) + x0
35 e = randn(n) * sigma
36 y = x * a + b
37 y += e
38 return vstack([x, y]).T