using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
namespace wsControls
{
public class wsArray
{
#region [ Static ] GetFrequency, GetChanPower, PeakSearch, SortTrace ... To Verify
public static decimal[] ApplyFrequency(decimal start, decimal stop, int nop)
{
decimal[] frequency = new decimal[nop];
decimal span = stop - start;
int interval = nop - 1;
for (int i = 0; i < nop; i++)
frequency[i] = start + i * span / interval;
return frequency;
}
public static decimal GetValue(decimal start, decimal stop, decimal nop, decimal index)
{
decimal span = stop - start;
return start + span * index / (nop - 1);
}
public static decimal GetValue(decimal[] array, decimal index)
{
return array[0] + (array[array.Length - 1] - array[0]) * index / (array.Length - 1);
}
public static decimal GetIndex(decimal start, decimal stop, int nop, decimal frequency)
{
decimal span = stop - start;
return (frequency - start) * (nop - 1) / span;
}
public static decimal GetIndex(decimal[] array, decimal frequency)
{
return (frequency - array[0]) * (array.Length - 1) / (array[array.Length - 1] - array[0]);
}
public static double GetChanPower(decimal[] trace, int startindex, int stopindex)
{
double p = 0D;
for (int i = startindex; i <= stopindex; i++)
{
p += Math.Pow(10D, (double)trace[i] / 10D);
}
return p < Math.Pow(10D, -17) ? -175 : 10 * Math.Log10(p);
}
public static decimal GetFlatnesss(decimal[] trace, int istart, int istop)
{
decimal max = trace[istart]; decimal min = trace[istart];
for (int i = istart+1; i <= istop; i++)
{
if (trace[i] > max)
{
max = trace[i];
continue;
}
if (trace[i] < min)
min = trace[i];
}
return max - min;
}
public static double GetChanPower(decimal[] trace, decimal span, decimal bandwidth)
{
decimal N = bandwidth * (trace.Length - 1) / span;
N = N / 2;
decimal istart = (trace.Length - 1) / 2 - N;
decimal istop = (trace.Length - 1) / 2 + N;
return GetChanPower(trace, (int)istart, istop - (int)istop > 0 ? (int)istop + 1 : (int)istop);
}
public static int[] SortMinMax(decimal[] trace)
{//From Min to Max
int[] index = new int[trace.Length];
for (int i = 0; i < index.Length; i++)
index[i] = i;
decimal[] sort = (decimal[])trace.Clone();
Array.Sort(sort, index, 0, index.Length);//from 0 -> N
//Array.Reverse(index);
return index;
}
public static int[] SortMinMax(Collection<decimal> trace)
{//From Min to Max
int[] index = new int[trace.Count];
for (int i = 0; i < index.Length; i++)
index[i] = i;
decimal[] sort = (decimal[])trace.ToArray();
Array.Sort(sort, index, 0, index.Length);//from 0 -> N
//Array.Reverse(index);
return index;
}
public static int[] SortMaxMin(decimal[] trace)
{
int[] index = SortMinMax(trace);
Array.Reverse(index);
return index;
}
public static decimal GetPeak(decimal[] trace, int istart, int istop)
{
decimal max = decimal.MinValue;
for (int i = istart; i <= istop; i++)
{
if (trace[i] > max)
max = trace[i];
}
return max;
}
public static int[] GetPeakIndex(decimal[] trace, int npeaks)
{
int[] peakindex = new int[npeaks];
int[] sortindex = SortMinMax(trace);
int n = 0;
int candidateindex;
for (int i = sortindex.Length - 1; i >= 0 && n < npeaks; i--)
{
candidateindex = sortindex[i];//peak index, n starts from 0
if (candidateindex == 0 )
{
if (trace[candidateindex] >= trace[candidateindex + 1])
{
peakindex[n] = candidateindex;
n++;
}
continue;
}
else if (candidateindex == sortindex.Length - 1 )
{
if (trace[candidateindex] >= trace[candidateindex - 1])
{
peakindex[n] = candidateindex;
n++;
}
continue;
}
else if (trace[candidateindex] >= trace[candidateindex - 1] && trace[candidateindex] >= trace[candidateindex + 1])
{
peakindex[n] = candidateindex;
n++;
continue;
}
}
return peakindex;
}
public static int[] GetPeakIndex(Collection<decimal> trace, int npeaks)
{
int[] peakindex = new int[npeaks];
int[] sortindex = SortMinMax(trace);
int n = 0;
int candidateindex;
for (int i = sortindex.Length - 1; i >= 0 && n < npeaks; i--)
{
candidateindex = sortindex[i];//peak index, n starts from 0
if (candidateindex == 0)
{
if (trace[candidateindex] >= trace[candidateindex + 1])
{
peakindex[n] = candidateindex;
n++;
}
continue;
}
else if (candidateindex == sortindex.Length - 1)
{
if (trace[candidateindex] >= trace[candidateindex - 1])
{
peakindex[n] = candidateindex;
n++;
}
continue;
}
else if (trace[candidateindex] >= trace[candidateindex - 1] && trace[candidateindex] >= trace[candidateindex + 1])
{
peakindex[n] = candidateindex;
n++;
continue;
}
}
return peakindex;
}
#endregion
}
}相关推荐
datart 二开环境搭建
下载源码, 地址: https://github.com/running-elephant/datart, dev 分支; 解压后使用 idea 打开; 服务端: 3.1 安装依赖, idea会自动安装; 3.2 修改配置文件 /config/application.yml 3.3 创建数据库,并将bin/datart.sql导入到数据库中 3.4 入口: /server/src/main/java/datart/DatartServerApplication.java [外链图片转存失败,源站可能有防.
后缀数组(SuffixArray) 学习笔记
后缀数组 前面有介绍过后缀树,后缀树对于我们针对某些字符串的处理使得如鱼得水,美中不足的是后缀树的代码实现复杂,只能让很多人望而却步。这次我们来介绍后缀树组:一个处理字符串的有力工具,也是一个后缀树的精美替代品,同样可以方便解决很多字符串问题。它比后缀树更加容易实现编码,也可以在不损失效率的情况下实现很多后缀树的功能,占用内存也比后缀树小很多,尤其是在模式匹配数据规模庞大的操作中实用性很
stata 代码实现熵值法计算 含常见问题解答
2.标准化①正向指标②负向指标。
WebSocket 实战--转
原文地址:http://www.ibm.com/developerworks/cn/java/j-lo-WebSocket/ WebSocket 前世今生 众所周知,Web 应用的交互过程通常是客户端通过浏览器发出一个请求,服务器端接收请求后进行处理并返回结果给客户端,客户端浏览器将信息呈现,这种机制对于信息变化不是特别频繁的应用尚可,但对于实时要求高、海量并发的应用来说显得捉襟见肘,尤其...
Circos图审美拯救计划:用TBtools复刻Nature级共线性分析图谱
本文针对Circos图在共线性分析中的审美提升问题,提供了一套基于TBtools的完整优化方案。通过构建和谐的色彩体系、精细控制信息层布局以及模仿顶刊构图逻辑,详细讲解了如何从配色、透明度、标签显示到高级参数设置,将默认图表升级为具有高级学术美感的Nature级图谱,助力研究者提升论文图表质量。
JAVA + 海康威视SDK + FFmpeg+ SRS 实现海康威视摄像头二次开发
海康威视SDK接入方案摘要 本文介绍了使用海康威视官方SDK开发物联网平台摄像头接入功能的完整方案。系统采用Java后端集成HCNetSDK控制摄像头,通过FFmpeg将RTSP流转为RTMP推送到SRS流媒体服务器,前端基于HTTP-FLV协议实现视频播放。文章详细说明了开发准备工作,包括SDK下载、SRS部署、FFmpeg安装等关键步骤,并提供了数据库表设计和接口定义。核心部分展示了如何集成海康SDK,包括提取必要代码、加载DLL文件、配置打包插件等具体实现细节,最终形成了一套支持实时预览、回放和下载的
C# 中的字体
C#中本来已经封装了通用字体Font,但是笔者认为这个Font在使用过程中很不方便。 1) Font的很多属性都是只读的,不能通过更改属性的值而对Font进行操作;必须重新初始化Font对象才行。例如:font.Size=12;是不允许的。 2) Font总归是用来写字的,但是C#中的Font类与string类没有什么联系,这给Font的使用带来了一些麻烦。比如我想要知道一个string对象使
Python量化入门:用pytdx获取800个交易日K线数据的完整指南(附代码)
本文为Python量化交易初学者提供了使用pytdx库免费获取股票日线级别K线数据的完整指南。文章详细介绍了从环境搭建、单只股票数据获取,到构建健壮的批量下载器、数据清洗与验证,再到基础分析与可视化的全流程,并附有可直接运行的代码示例,帮助读者快速建立本地股票数据库。
FileAssociation
using System; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; using Microsoft.Win32; namespace wsWin { #region [ FileAssociation ] public class FileAssoci
leetcode134 加油站
题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...
GEE 案例分析:利用Landsat数据进行FAI、NDVI及CHLA分析并统计平均值(巢湖为例)
浮游藻类指数(FAI)、归一化植被指数(NDVI)及叶绿素a(CHLA)是水体环境监测的重要指标。本文利用Google Earth Engine(GEE)平台,基于Landsat 5和Landsat 8数据,进行水体藻类及植被监测。
c# 后台程序
C# 中的backgroundworker,是我个人认为最具有吸引力的windows标准控件之一,他允许程序在后台运行一个独立的线程,而不影响前台主窗口。这种进程控制在操作数据库或通讯时非常实用,因为后台线程在工作时并不影响前台的任何操作。如果不使用backgroundworker而简单的应用单一线程操作,则通讯时很有可能会造成主窗口假死,知道通讯结束后才会恢复。下面简单介绍backgroundw
Codex 100个真实案例 - 用AI做股票K线分析工具(技术指标全自动)
本案例将用 Codex 从零搭建一个完整的股票 K 线分析工具。通过自然语言驱动,我们让 AI 自动完成股票数据获取(akshare)、K 线图绘制(mplfinance + ECharts)、技术指标计算(MA/EMA/MACD/RSI/KDJ/布林带)、买卖信号提示(金叉/死叉、超买超卖)、多股对比分析、Web 可视化界面(Flask + ECharts)、PDF 报告生成以及定时监控邮件推送等全套功能。全程用自然语言指令驱动 Codex,零手写代码实现专业级量化分析平台!
C# 打开外部文件
System.Diagnostics.Process.Start(".//Help.chm");
Statistics and Machine Learning Toolbox
Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具
ET2012新版免狗免安装绿色软件
ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,
StringX
namespace wsControls { public class StringX { public static char mylar = (char)220; #region [ Property ] String public string String { get; set; } #endregion
visio安装包
Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。
CDataGrid
enum DataMask { Num, Float, Date, NvChar, Bit }; [ToolboxBitmap(typeof(System.Windows.Forms.DataGridView))] class CDataGrid : DataGridView { public DataMask val_type; publi
SIMATIC S7-1200, S7-1500 PID 控制[手册]
SIMATIC S7-1200, S7-1500 PID 控制[手册]
ListView 到 Excel
using System.Reflection; Function() { Excel.Application app = new Excel.Application(); if (app == null) { MessageBox.Show("Failed to Load Excel,Pleas
win32
using System; using System.Runtime.InteropServices; using System.Drawing; using System.Text; namespace wsWin { public class Win32 { public const int GW_HWNDFIRST = 0; public
读写文件
BackgroundWorker background1 = new BackgroundWorker();byte[] buffer1;//HDD -> MEM BackgroundWorker background2 = new BackgroundWorker();byte[] buffer2;//MEM -> HDD UInt32 pointer1, pointer2; bool abor
ini, Reg
using System.Text; using Microsoft.Win32; namespace wsWin { #region [ *.ini file ] public class InI { public string path; public InI(string INIPath) {
User Define Message
You need total 3 steps to define your message [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wPar, IntPtr lPar); public const int UserMsg =
DataGrid导出到Ex el, 自动获取列标识
#region [ 导出到Excel ] public void Export() { #region range int count = this.Columns.Count; if (count > 256 || count == 0)//超出Excel的最大行数,
wsFile
using System; using System.Collections.ObjectModel; using System.Data; using System.Drawing; using System.IO; using System.Text; namespace wsControls.IO { public class wsFile { publi
读写操作,文件和注册表
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Win32; using System.Text; 读写INI文件 public class InI { public string path; #region -- Dll I
Copy文件
private void bRun_Click(object sender, EventArgs e) { byte[] buffer; int blocksize = 4096; try { FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open);
6133



被折叠的 条评论
为什么被折叠?



