栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

211230-一维时间序列随机连续采样

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

211230-一维时间序列随机连续采样

import numpy as np

data = np.arange(200).reshape(-1,1)
fea = 6
sap = 10
interval = 32
ctn = 5
zone = np.random.randint(1, len(data)-fea-interval*ctn, sap)
print('Random sampling')
print(data.shape)
print(zone)
print(len(zone),'n')


ctn_arr = []
zone = np.array([np.arange(z, z+interval*ctn, 32) for z in zone]).ravel()
print('Random continuous sampling')
print(zone.reshape(sap,-1), 'n')

zone = zone.ravel()


slic = np.array([data[i:i+fea, :] for i in zone]).squeeze()
print('Final sampled data matrix')
print(slic.shape)

Random sampling
(200, 1)
[31  4 11 30 28 25 30 15 10 33]
10 

Random continuous sampling
[[ 31  63  95 127 159]
 [  4  36  68 100 132]
 [ 11  43  75 107 139]
 [ 30  62  94 126 158]
 [ 28  60  92 124 156]
 [ 25  57  89 121 153]
 [ 30  62  94 126 158]
 [ 15  47  79 111 143]
 [ 10  42  74 106 138]
 [ 33  65  97 129 161]] 

Final sampled data matrix
(50, 6)
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/689571.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号