博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
利用线性回归模型进行卫星轨道预报
阅读量:6394 次
发布时间:2019-06-23

本文共 3063 字,大约阅读时间需要 10 分钟。

数据

300,21182.88,-7044.56,14639.48600,21707.87,-6930.28,13906.68900,22207.04,-6828.65,13147.661200,22679.16,-6738.66,12363.841500,23123.06,-6659.23,11556.711800,23537.69,-6589.21,10727.782100,23922.07,-6527.40,9878.612400,24275.33,-6472.54,9010.812700,24596.67,-6423.32,8126.003000,24885.42,-6378.40,7225.863300,25141.01,-6336.41,6312.083600,25362.96,-6295.93,5386.383900,25550.92,-6255.54,4450.51

问题

图片描述

图片描述
图片描述

def read_m(path):    #  所有数据    m = []    # x    xlist = []    # y    ylist = []    # z    zlist = []    # time    time_list = []    with open(path, 'r') as f:        for i in f.readlines():            aa = i.replace('\n', '').split(",")            bb = [eval(a) for a in aa]            m.append(bb)            time_list.append(bb[0])            xlist.append(bb[1])            ylist.append(bb[2])            zlist.append(bb[3])    return {        "alldata": m,        "time": time_list,        "x": xlist,        "y": ylist,        "z": zlist,    }XXX = NoneYYY = Nonedef xpj():    """    X平均值    :return:    """    sum = 0    for i in range(XXX.__len__()):        sum += XXX[i]    return sum / XXX.__len__()def ypj():    """    Y 平均值    :return:    """    sum = 0    for i in range(YYY.__len__()):        sum += YYY[i]    return sum / YYY.__len__()def sse():    """    回归方程    :return:    """    sum = 0    xa = xpj()    ya = ypj()    for i in range(XXX.__len__()):        sum += (XXX[i] - xa) * (YYY[i] - ya)    return sumdef ssx():    """    回归方程    :return:    """    sum = 0    xa = xpj()    for i in range(XXX.__len__()):        sum += (XXX[i] - xa) * (XXX[i] - xa)    return sumdef getbeta1():    """    bate1    :return:    """    bbeta = sse() / ssx()    return bbetadef getbeta0():    """    beta0    :return:    """    return ypj() - getbeta1() * xpj()def huiguixishu(x, y):    """    回归系数    :param x:    :param y:    :return:    """    global XXX    global YYY    XXX = x    YYY = y    beta1 = getbeta1()    beta0 = getbeta0()    return [beta0, beta1]def predic(x, beta0, beta1):    """    估计    :param x:    :param beta0:    :param beta1:    :return:    """    a = beta0 + beta1 * x    return aif __name__ == '__main__':    d = read_m("轨道文件.txt")    tm = d["time"]    x = d["x"]    y = d["y"]    z = d["z"]    print("========回归系数=========")    a = huiguixishu(tm, x)    b = huiguixishu(tm, y)    c = huiguixishu(tm, z)    print(a)    print(b)    print(c)    print("========预测=========")    guji_time = [4200,4500,4800]    beta0_list = [a[0],b[0],c[0]]    beta1_list = [a[1],b[1],c[1]]    for i in range(guji_time.__len__()):        x = predic(guji_time[i],beta0_list[0],beta1_list[0])        y = predic(guji_time[i],beta0_list[1],beta1_list[1])        z = predic(guji_time[i],beta0_list[2],beta1_list[2])        print(guji_time[i],format(x,'0.3f') ,format(y,'0.3f'),format(z,'0.3f'))

结果

========回归系数=========[21146.959615384614, 1.2183738095238088][-7019.398461538461, 0.21143040293040288][15712.87576923077, -2.8401093406593407]========预测=========4200 26264.130 -6131.391 3784.4174500 26629.642 -6067.962 2932.3844800 26995.154 -6004.533 2080.351

转载地址:http://nwgha.baihongyu.com/

你可能感兴趣的文章
3分钟搭建Ant Design Pro前端开发环境( MyClouds的前端选型)
查看>>
Linux系统常用命令(二)
查看>>
简单的工厂模式学习
查看>>
温习如何画E-R图
查看>>
eclispe注释模板
查看>>
Thymeleaf教程 (三) 创建一个多语言的首页
查看>>
OSChina 周六乱弹 ——你们猜狗的舌头有多长
查看>>
OSChina 周日乱弹 —— 爱丽丝爱吃京酱肉丝
查看>>
2018.11月微信小程序优质开源项目
查看>>
IOS 未来几年的认知
查看>>
解决中文乱码--加密
查看>>
浅析全民社交创业梦
查看>>
Java操纵MongoDB_1(环境设置)
查看>>
C#字符串操作--获取字符或字符串的位置、数量
查看>>
php - 字符串处理
查看>>
bulk collect 以及ref cursor使用
查看>>
mysql性能优化-慢查询分析、优化索引和配置
查看>>
图解分布式一致性协议Paxos
查看>>
Jedis与Redisson选型对比
查看>>
MongoDB学习笔记(查询)
查看>>