zoukankan      html  css  js  c++  java
  • Intermezzo: A Data Analysis Session

    # -*- coding: utf-8 -*-
    """
    Created on Wed Nov 05 15:18:17 2014
    
    @author: dell
    """
    
    import pandas as pd
    import numpy as np
    import datetime
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    
    if __name__ == '__main__':
        df = pd.read_table('carbon.dioxide.txt', header = None)
        data = np.array(list(df[0].values))
        
        fig = plt.figure()
        ax = fig.add_subplot(331)
        ax.plot(data)
        
        x = np.linspace(1, len(data), len(data))
        ax1 = fig.add_subplot(332)
        ax1.plot(data-315)
        ax1.plot(((x/350)**2)*35,'--')
        
        ax3 = fig.add_subplot(333)
        ax3.plot(data-315)
        ax3.plot(((x/350)**1.35)*35, '--')
        
        ax4 = fig.add_subplot(334)
        myres = data-315-((x/350)**1.35)*35
        ax4.plot(myres)
    
        ax1 = fig.add_subplot(335)
        from scipy.interpolate import UnivariateSpline
        #xs = np.linspace(1, len(data), len(data)*100)
        xs = np.linspace(1, len(data), 1000)
        s = UnivariateSpline(x, myres)
        ys = s(xs)
        ax1.plot(xs, ys)
        ax1.plot(myres)
        
        ax2 = fig.add_subplot(336)
        ax2.plot(myres)
        ax2.plot(3*np.sin(2*np.pi*x/12))
        
        ax3 = fig.add_subplot(337)
        myres1 = myres - 3*np.sin(2*np.pi*x/12) 
        #myres2 = data - 315-35*(x/350)**1.35 - 3*np.sin(np.pi*2*x/12)
        s1 = UnivariateSpline(x, myres1, s = 850)
        ys1 = s1(xs)
        ax3.plot(xs, ys1)
        ax3.plot(myres1)
        ax3.axhline(y = 1, ls = '--')
        ax3.axhline(y = -1, ls = ':')
        
        ax8 = fig.add_subplot(338)
        myfun = 315 + (x/350)**1.35*35 + 3*np.sin(2*np.pi*x/12) + 0.75*np.sin(2*np.pi*x/6) + 0.1
        ax8.plot(myfun, ls=':')
        ax8.plot(data)
        
        ax9 = fig.add_subplot(339)
        x = np.linspace(1, 800, 800)
        myfun = 315 + (x/350)**1.35*35 + 3*np.sin(2*np.pi*x/12) + 0.75*np.sin(2*np.pi*x/6) + 0.1
        ax9.plot(myfun, ls=':')
        ax9.plot(data)
        ax9.set_xlim(1, 800)
        
        plt.show()

    https://files.cnblogs.com/hluo/carbon.dioxide.rar 

    样条平滑函数还没有弄明白回事。

  • 相关阅读:
    健康检查详解:机制、配置、对比、实操
    制作自签名证书
    常用的UML建模
    UML建模更好的表达产品逻辑
    常用的UML建模
    UML建模图实战笔记
    领域驱动设计学习之路—DDD的原则与实践
    DDD领域驱动设计理论篇
    WAN、LAN、WLAN三种网口的区别
    新生代Eden与两个Survivor区的解释
  • 原文地址:https://www.cnblogs.com/hluo/p/4078185.html
Copyright © 2011-2022 走看看