日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab容差,绝对值容差 - MATLAB- MathWorks 中国

發布時間:2023/12/31 循环神经网络 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab容差,绝对值容差 - MATLAB- MathWorks 中国 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

創建一個供交互測試的測試用例。

import matlab.unittest.TestCase

import matlab.unittest.constraints.IsEqualTo

import matlab.unittest.constraints.AbsoluteTolerance

import matlab.unittest.constraints.RelativeTolerance

testCase = TestCase.forInteractiveUse;

定義兩個包含真空吸塵器的電磁屬性的結構體。一個結構體 approxVacuumProps 包含真空吸塵器中光源的滲透率和速度的近似值。

approxVacuumProps.Permeability = 1.2566e-06; % Approximate

approxVacuumProps.Permitivity = 8.854187817*10^-12;

approxVacuumProps.LightSpeed = 2.9979e+08; % Approximate

baselineVacuumProps.Permeability = 4*pi*10^-7;

baselineVacuumProps.Permitivity = 8.854187817*10^-12;

baselineVacuumProps.LightSpeed = 1/sqrt(...

baselineVacuumProps.Permeability*baselineVacuumProps.Permitivity);

測試近似值和基準值之間的相對差是否處于 eps*1e11 內。

testCase.verifyThat(approxVacuumProps, IsEqualTo(baselineVacuumProps, ...

'Within', RelativeTolerance(eps*1e11)))

Verification failed.

---------------------

Framework Diagnostic:

---------------------

IsEqualTo failed.

--> Path to failure: .Permeability

--> NumericComparator failed.

--> The numeric values are not equal using "isequaln".

--> RelativeTolerance failed.

--> The error was not within relative tolerance.

--> Failure table:

Actual Expected Error RelativeError RelativeTolerance

__________ ____________________ _____________________ _____________________ ____________________

1.2566e-06 1.25663706143592e-06 -3.70614359173257e-11 -2.94925536216295e-05 2.22044604925031e-05

Actual double:

1.256600000000000e-06

Expected double:

1.256637061435917e-06

Actual struct:

Permeability: 1.256600000000000e-06

Permitivity: 8.854187816999999e-12

LightSpeed: 299790000

Expected struct:

Permeability: 1.256637061435917e-06

Permitivity: 8.854187816999999e-12

LightSpeed: 2.997924580105029e+08

測試失敗,原因是滲透率的相對差不處于容差范圍內。兩個值之間的差較小,但數值接近于零,因此該差相對于其大小來說并不足夠小,不滿足該容差。

構造一個容差對象,以測試是否近似值和基準值之間的絕對差處于 1e-4 范圍內。

testCase.verifyThat(approxVacuumProps, IsEqualTo(baselineVacuumProps, ...

'Within', AbsoluteTolerance(1e-4)))

Verification failed.

---------------------

Framework Diagnostic:

---------------------

IsEqualTo failed.

--> Path to failure: .LightSpeed

--> NumericComparator failed.

--> The numeric values are not equal using "isequaln".

--> AbsoluteTolerance failed.

--> The error was not within absolute tolerance.

--> Failure table:

Actual Expected Error RelativeError AbsoluteTolerance

_________ ________________ _________________ ____________________ _________________

299790000 299792458.010503 -2458.01050287485 -8.1990404935028e-06 0.0001

Actual double:

299790000

Expected double:

2.997924580105029e+08

Actual struct:

Permeability: 1.256600000000000e-06

Permitivity: 8.854187816999999e-12

LightSpeed: 299790000

Expected struct:

Permeability: 1.256637061435917e-06

Permitivity: 8.854187816999999e-12

LightSpeed: 2.997924580105029e+08

測試失敗,原因是光速的絕對差不處于容差范圍內。兩個值之間的差相對于其大小來說較小,但要滿足容差又太大。

構造容差對象的邏輯析取,以測試是否近似值和基準值之間的絕對差處于 1e-4 范圍內或相對差處于 eps*1e11 范圍內。測試使用此容差,這樣接近于零的滲透率值滿足絕對(下限)容差,較大的光速值滿足相對誤差。

testCase.verifyThat(approxVacuumProps, IsEqualTo(baselineVacuumProps, ...

'Within', RelativeTolerance(eps*1e11)| AbsoluteTolerance(1e-4)))

Verification passed.

總結

以上是生活随笔為你收集整理的matlab容差,绝对值容差 - MATLAB- MathWorks 中国的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。