• 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

  • 相关阅读:
    jtopo
    转载model2
    转载model
    Vue -- 后台系统布局导航栏
    Vue -- iview表格 axiso调用接口数据
    Vue -- 视频&&下载 组件
    Vue -- echarts 折线图demo
    Vue -- axios封装
    Vue -- 验证码
    01 & 02 & 03笔记
  • 原文地址:https://www.cnblogs.com/gisalameda/p/11367849.html
Copyright © 2020-2023  润新知