试证明,∇ATr(ABATC)=CAB+CTABT

本文针对Andrew Ng在《斯坦福大学公开课:机器学习课程》中给出的一个矩阵迹的导数公式进行详细推导证明,利用矩阵运算的基本性质,如转置、迹的性质等完成证明。

作者来自:Joy

在阅读《斯坦福大学公开课 :机器学习课程》时,Andrew Ng给出一个矩阵的式子,


没有给出推导过程。

现在发扬作者打破沙锅问到底的精神,试证明之, prove它

方阵的迹,导数概念先参看 

http://blog.youkuaiyun.com/dddddttttt/article/details/79520934

首先,列出准备的式子。


1,tr(AB)=tr(BA)

2, tr(A)=tr(AT)

3,   ATr(AB)=BT  
4,    (AB)^ T= B^T A^T
5, (uv)'=u'v+uv'          (multivariate derivative rule)

做好准备以后正式开始吐舌头

第一行 X标记A,利用第五式

第二行  左边利用第三式,右边利用第一式

第三行 左边利用第四式,右边利用第一式和第四式

第四行 右边利用第三式

第五行  得证





修改错误//@version=2 strategy("增强AI交易策略", overlay=true, pyramiding=1, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.1) // 输入参数 stopLoss = input(2, title="止损百分比(%)") takeProfit = input(4, title="止盈百分比(%)") maFastLen = input(8, title="快速EMA周期") maSlowLen = input(21, title="慢速EMA周期") rsiLen = input(14, title="RSI周期") macdFast = input(12, title="MACD快线") macdSlow = input(26, title="MACD慢线") macdSignal = input(9, title="MACD信号线") atrLen = input(14, title="ATR周期") adxLen = input(14, title="ADX周期") // 移动平均线 emaFast = ema(close, maFastLen) emaSlow = ema(close, maSlowLen) maTrend = emaFast > emaSlow // RSI rsi = rsi(close, rsiLen) rsiBullish = rsi > 50 rsiBearish = rsi < 50 // MACD [macdLine, signalLine, _] = macd(close, macdFast, macdSlow, macdSignal) macdBullish = macdLine > signalLine macdHistogram = macdLine - signalLine // ATR用于波动性分析 atr = atr(atrLen) volatility = atr / close * 100 // ADX用于趋势强度 adx = adx(adxLen) adxTrend = adx > 25 // 成交量分析 volumeSma = sma(volume, 20) volumeHigh = volume > volumeSma * 1.2 // 价格行为 higherHigh = high > high[1] higherLow = low > low[1] lowerHigh = high < high[1] lowerLow = low < low[1] // 多时间框架分析 rsiDaily = security(tickerid, 'D', rsi(close, rsiLen)) rsiTrend = rsiDaily > 50 // AI信号评分系统 score = 0 // 趋势得分 (最大30分) if maTrend score := score + 15 if adxTrend score := score + 15 // 动量得分 (最大30分) if macdBullish score := score + 15 if rsiBullish score := score + 15 // 成交量确认 (最大20分) if volumeHigh and close > open score := score + 20 // 价格行为得分 (最大20分) if higherHigh and higherLow score := score + 20 AICoin自定义指标函数文档 - AiCoin https://www.aicoin.com/article/355796.html // 多时间框架确认 (额外加分) if rsiTrend score := score + 10 // 风险管理 - 根据波动性调整仓位 positionSize = volatility < 2 ? strategy.equity * 0.15 : volatility < 5 ? strategy.equity * 0.1 : strategy.equity * 0.05 // 生成交易信号 buySignal = score >= 70 and not maTrend[1] and maTrend sellSignal = score < 30 and maTrend[1] and not maTrend // 止损止盈计算 longStop = strategy.position_avg_price * (1 - stopLoss/100) longTakeProfit = strategy.position_avg_price * (1 + takeProfit/100) // 执行交易 if (buySignal) strategy.entry("Long", strategy.long, qty=positionSize) if (strategy.position_size > 0) if (low <= longStop) strategy.close("Long", comment="止损") else if (high >= longTakeProfit) strategy.close("Long", comment="止盈") else if (sellSignal) strategy.close("Long", comment="趋势反转") // 可视化 plot(emaFast, color=blue, linewidth=2, title="快速EMA") plot(emaSlow, color=red, linewidth=2, title="慢速EMA") // 信号标记 plotshape(buySignal, style=shape.triangleup, location=location.belowbar, color=green, size=size.small, title="买入信号") plotshape(sellSignal, style=shape.triangledown, location=location.abovebar, color=red, size=size.small, title="卖出信号") // 背景色 bgcolor(buySignal ? lime : sellSignal ? red : na, transp=80) // 显示分数 var label scoreLabel = na if barstate.islast scoreLabel := label.new(bar_index, high, text="AI分数: " + tostring(score), color=score >= 70 ? green : score < 30 ? red : gray, style=label.style_label_down, textcolor=white) // 警报 alertcondition(buySignal, title="AI买入信号", message="AI策略建议买入") alertcondition(sellSignal, title="AI卖出信号", message="AI策略建议卖出")
最新发布
11-26
评论 7
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值