Skip to Content
Mathematica 錦囊妙計
book

Mathematica 錦囊妙計

by Sal Mangano
April 2014
Beginner to intermediate
830 pages
15h 21m
Chinese
GoTop Information, Inc.
Content preview from Mathematica 錦囊妙計
2.6 對移動子串列進行函數映射
|
45
討論說明
前文闡述的是基本概念,但不易推廣,因為窗口大小與目標函數都固定在程式碼內。以
下提供可使用任意窗口大小與目標函數的指令。
事實上 Mathematica 內建有
MovingAverage
與
MovingMedian
指令可計算移動平均數與移
動中位數,其中
MovingAverage
也可指定權重。當你需要運算移動平均數與移動中位數
時,建議使用內建函數,它們能提供較佳的執行效率。
Mathematica 提供兩個特別指令:
ListConvolve
與
ListCorrelate
,用來進行更廣義的子
串列運算,它們的功能很多,花些時間深入了解是很值得的。以下只針對
ListConvolve
指令做介紹,因為這兩個指令在使用上相似,只是針對不同問題處理的方式不同。我們
就從移動平均數的計算介紹起。
ListConvolve
指令的第一個引數稱為
核心
(
kernel
),它是一個數字串列,用來定義子
串列的長度及權重,子串列將與核心相乘後再加總起來。以下使用符號使你更容易了解
運作。
此處使用簡單的核心
{1,1}
,其代表子串列的長度為 2,且每個元素會直接相加(因為
乘以 1 的結果仍不變),因此運算結果為連續子串列的和。只要將核心除以
n
便可得到
移動平均數。[Page-045]
這可輕易推廣至加權移動平均數,在此就不多做介紹了,畢竟 Mathematica 已提供了內
建指令。以下繼續討論
ListConvolve
指令。
ch02.indd 45 2014/4/2 上午 03:32:12 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Mathematica Cookbook

Mathematica Cookbook

Sal Mangano
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9789863470106