#!/usr/bin/env python3 import numpy as np # https://numpy.org/doc/stable/reference/random/generated/numpy.random.randn.html#numpy.random.randn x = np.random.randn( 100 ) * 5 + 10 print('x:\n',x) print('Suma elementos x: ',x.sum()) print('Media x:',x.mean()) print('Varianza estándar x:',x.std()) print('Varianza x:',x.var()) y = np.random.randn( 100 ) * 3 - 7 xy = np.vstack( [ x, y ] ) print('----------') print('xy shape:',xy.shape) # (2, 100) print('xy:\n',xy) print('----------') print('Covariance matrix:\n\n',np.cov(xy)) print('----------') xy = np.random.multivariate_normal( [7,5], [[36,-9],[-9,49]], 10) xy.sum(axis=1) xy.mean(axis=0) xy.std(axis=0) xy.var(axis=0) x = np.random.rand( 10000 ) * 100 hist,bin_edges = np.histogram( x, bins=20, density=False ) print( hist ) hist,bin_edges = np.histogram( x, bins=20, density=True ) print( hist, hist.sum(), bin_edges[1]-bin_edges[0] ) print( bin_edges ) # The same in both cases