The ewm() function is used to provide exponential weighted functions. 指数加权功能。
1 2 3 4 5 6 7 8 9 10
import pandas as pd
# Creating the series. Using the range() function, we create a series and set the index to shot. my_series=pd.Series(range(1,20,5), index=[x for x in'shot'])
# Printing the series print(my_series)
# Using Series.ewm(). We calculate the exponential weight of elements in the series using the ewm() function and set the com and adjust parameters. print(my_series.ewm(com=0.5, adjust=True).mean())
com: This represents the decay in terms of the center of mass, α=1/(1+com), for com≥0. 根据Center of Mass质心指定衰减。
span: This represents the decay in terms of the span, α=2/(span+1), for span≥1. 根据跨度范围(例如,天数)指定衰减。
halflife: This represents the decay in terms of the half-life, α=1−exp(log(0.5)/halflife), for halflife>0. 根据半衰期指定衰减。
alpha: This indicates smoothing factor α, 0<α≤1. 衰减系数。
min_periods: This represents the minimum number of observations needed to have a value in the window. The default value is 0.
adjust: This is divided by the decaying adjustment factor into the initial periods to consider the imbalance in the relative weightings (looking at the EWMA as a moving average). 计算权重的方式。
ignore_na: This specifies that the missing values should be ignored when calculating weights. The default is False. 如何对待空值。
axis: The default value is 0. It specifies the axis on which the function is to be performed. If the value is 0, the operation is performed across the rows. Otherwise, the operation is performed across the columns. 数轴。
func(f *FSM) enterStateCallbacks(e *Event){ if fn, ok := f.callbacks[cKey{f.current, callbackEnterState}]; ok { fn(e) } if fn, ok := f.callbacks[cKey{"", callbackEnterState}]; ok { fn(e) } }
接着,笔者翻阅内外网有同样场景的解决方案,基本都是往经典Reactor模型实现上做文章。比如最早的A Million WebSockets and Go,作者Sergey Kamardin使用epoll的方式代替goroutine-per-conn模式,百万连接场景下用少量的goroutine去代替一百万的goroutine。
Main Reactor主要负责监听和接收连接,接着分配连接,它里边有个for循环,不断去accept新连接,这里的方法可以叫做acceptorLoop;Sub Reactor拿到Main Reactor分配的连接,它也是个for循环,一直等待着读写事件到来,然后干活,即回调应用层执行具体业务逻辑,它的方法可以叫做readWriteLoop。
3.1 DID wallet,展示个人信息(e.g. 姓名/年龄/地址),NTF形式展示 SBT(门票/社区会员),ZKP以及验证。 3.2 DID Reputation,true-ownership(个人金融评分,教育经历,社交凭证,专业能力-blockhat),Reward&Punishment 奖惩机制(认证节点 —> 发型,认证,检举,惩罚,对认证节点进行分级,早期邀请背调公司作为高级认证节点),辅助以 AI 技术对流程进行作弊发现。应用于Token精准airdrop,lending,联合其他DID-SBT。