zoukankan      html  css  js  c++  java
  • Simulating noise-free and noise-corrupted data

    %matplotlib inline
    import numpy as np
    import matplotlib.pyplot as plt
    
    # number of data
    N = 31
    
    # coordinates of the data
    x = np.linspace(0., 30., N)
    
    xmax = np.max(x)
    xmin = np.min(x)
    Dx = xmax - xmin
    
    # true constants a and b
    a = -5.
    b = 0.1
    
    # noise-free data vector
    d_free = a + b*x
    
    # Gaussian noise with null mean and standard deviation defined 
    #by the variable stdev
    stdev = 0.3
    noise = np.random.normal(loc = 0., scale=stdev, size=N)
    
    # noise-corrupted data
    d_noise = d_free + noise
    
    dmin = np.min(d_noise)
    dmax = np.max(d_noise)
    Dd = dmax - dmin
    
    plt.close('all')
    plt.figure(figsize=(10,8))
    plt.plot(x, d_free, 'ko', label='noise-free data')
    plt.plot(x, d_noise, 'ro', label='noise-corrupted data')
    plt.xlim(xmin - 0.05*Dx, xmax + 0.05*Dx)
    plt.ylim(dmin - 0.05*Dd, dmax + 0.05*Dd)
    plt.xlabel('x', fontsize=14)
    plt.ylabel('data', fontsize=14)
    plt.grid()
    plt.legend(loc='best', fontsize=12)
    plt.show()
    

      https://github.com/birocoles/Disciplina-metodos-computacionais/blob/master/Content/least_squares.ipynb

  • 相关阅读:
    Excel电子表格操作
    word文档编辑
    中英文输入
    个人借款合同范本
    Day-8:汇总数据
    Day-7:使用函数处理数据
    Day-6:创建计算字段
    Day-5:通配符过滤
    Day-4:高级数据过滤
    Day-3:过滤数据
  • 原文地址:https://www.cnblogs.com/gisalameda/p/11367849.html
Copyright © 2011-2022 走看看