NumPy Application: Determining Moore‘s Law with real data in NumPy

这篇博客对比了1965年Gordon Moore的预测与过去53年间实际晶体管数量的增长。通过加载历史数据,执行最小二乘法线性回归,确定了半导体上晶体管指数增长的常数。内容包括从CSV文件加载数据、执行线性回归、保存分析结果以及创建CSV文件。最后,博客展示了如何预测特定年份的晶体管数量,并保存了所有相关数据。
摘要由CSDN通过智能技术生成

在这里插入图片描述
每个给定芯片上的晶体管数量绘制在 y 轴上的对数刻度上,线性刻度上的引入日期在 x 轴上。
蓝色的点表示晶体管记数表;红色的线是最小二乘预测;橙色的线是摩尔定律
将要做的事
背景知识:1965年,工程师Gordon Moore预测在未来十年内,芯片上的晶体管数量将每两年翻一番。
本篇将在摩尔预测之后的53年将其预测与实际晶体管数量进行比较。
与摩尔定律相比,将确定最适合的常数来描述半导体上晶体管的指数增长。
本篇涉及到的知识

  • 从*.csv文件中加载数据
  • 使用最小二乘法来执行线性回归并预测指数增长
  • 比较模型之间的指数增长常数
  • 将分析结果存储为*.npz和*.csv文件中
  • 评估半导体制造商在过去五年中取得的进步

接下来会使用到的函数功能说明

  • np.loadtxt:this function loads text into a Numpy array
  • np.log:this function takes the natural log(自然对数) of all elements in a Numpy array
  • no.exp:this function takes the exponential of all elements in a Numpy array(计算以e为底的指数)
  • lamba:this is a minimal function definition for creating a function model(创建模型的最小函数定义)
  • plt.semilogy:this function will plot x-y data onto a figure with a linear x-axis and log10 y-axis(此函数会将 x-y 数据绘制到具有线性 x 轴和 log10 y 轴的图形上)
  • plt.plot:this function will plot x-y data on linear axes;
  • sm.OLS :find fitting parameters and standard errors using the statsmodels ordinary least squares model(使用 statsmodels 普通最小二乘模型查找拟合参数和标准误差)
  • slicing arrays:view parts of the data loaded into the workspace,slice the arrays.e.g.x[:10] for the first 10 values in the array,x
  • boolean array indexing:to view parts of the data that match a given condition use boolean operations to index an array
  • np.block:to combine arrays into 2D arrays
  • np.newaxis:to change a 1D vector to a row or column vector
  • np.savaz an np.savatxt:these two functions will save your arrays in zipped array format and txt,respectively

moore law
1.您的经验模型假设每个半导体的晶体管数量呈指数增长,ln(transistor_count) = f(year) = A * year + B, A,B是fitting constant;式子变形得 transisor_count = e(Am*year+Bm)(Am,Bm,是每两年晶体管数量翻一番的常数,从 1971 年的 2250 个晶体管开始)
在这里插入图片描述
算出Am = 0.3466,Bm = -675.4

A_M = np.log(2) / 2 #np.log(2) 默认以e为底,np.log10(2) 以10为底
B_M = np.log(2250) - A_m * 1971
Moores_law = lambda year: np.exp(B_M) * np.exp(A_M * year)
# 根据摩尔定律,每个半导体上的晶体管数量每两年翻一番
ML_1971 = Moores_law(1971)
ML_1973 = Moores_law(1973)
print("In 1973,G. moore {:.0f} transistors on Intels chip".format(ML_1971))
print("This is x{:.2f} more transistors than 1971".format(ML_1973 / ML_1971))
# 输出
> In 1973, G. Moore expects 4500 transistors on Intels chips This is
> x2.00 more transistors than 1971

将历史工厂的数据加载到工作区间

NOW,make a prediction based

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值