From Test-Scratch-Wiki

(Created page with "thumb|137px|The median of a set of five numbers. This tutorial will explain how to find the median of numbers. The median of a set of numbers is the middle...")
 
Line 1: Line 1:
 
[[File:Median.png|thumb|137px|The median of a set of five numbers.]]
 
[[File:Median.png|thumb|137px|The median of a set of five numbers.]]
This tutorial will explain how to find the median of numbers. The median of a set of numbers is the middle value. If the set of numbers has an even amount, the median is the average of the two middle numbers. For more information, see [[Wikipedia:Median|Wikipedia]].
+
本教程将解释如何找到数字的中位数。一组数字的中位数是中间值。如果这组数字是偶数个,则中位数是两个中间数字的平均值。欲了解更多信息, 请参[[Wikipedia:Median|维基百科]].
  
== Sorting the Values ==
+
== 对值进行排序 ==
 
{{main|Sorting Values}}
 
{{main|Sorting Values}}
The first step in finding the median is to sort the data from least to greatest. Doing this first will make this finding the median much easier.
+
找到中位数的第一步是将数据从最小到最大排序。首先这样做会使这个发现的中位数容易得多。
  
== Finding the Median ==
+
== 查找中位数 ==
First, [[Sorting Algorithms|sort]] the values in order.
+
首先,按大小 [[Sorting Algorithms|排序]] .
  
Once the values have been sorted, use the following script to get the median. Remember that the [[list]] "Data" contains the set of values. The [[variable]]s "Med1" and "Med2" represent the values that will be used to solve for the median.
+
一旦这些值被排序,使用下面的脚本来获得中位数。请记住,“列表甲” 列表包含一组数字值。该变量 “中数1”和“中数1”表示将用于存放中位值的两个变量。
  
<scratchblocks>set [Med1 v] to (item ((length of [data v]) / (2)) of [data v])
+
 
set [Med2 v] to (item (((length of [data v]) / (2)) + (1)) of [data v])
+
<scratchblocks>
if < ((length of [data v]) mod (2)) = (0)> then
+
变量 [中数1 v] 设为 (链表第 ((length of [列表甲 v] :: list) / (2)) 项项目\( [列表甲 v] \) :: list)
say (join [median=] (((Med1) + (Med2)) / (2))) for (2) secs
+
变量 [中数2 v] 设为 (链表第 (((length of [列表甲 v] :: list) / (2)) + (1)) 项项目\( [列表甲 v] \) :: list)
else
+
如果 <((length of [列表甲 v] :: list) mod (2)) = (0)> 那么
say (join [median=] (item (((length of [data v]) / (2)) + (0.5)) of [data v])) for (2) secs
+
  说出 (字串组合 [中数值=] (((中数1) + (中数2)) / (2))) (2)
 +
否则
 +
  说出 (字串组合 [中数值=] (链表第 (((length of [列表甲 v] :: list) / (2)) + (0.5)) 项项目\( [列表甲 v] \) :: list)) (2)
 
end
 
end
 
</scratchblocks>
 
</scratchblocks>
  
== See Also ==
+
== 相关链接 ==
 
*[[Finding the Mean of Numbers]]
 
*[[Finding the Mean of Numbers]]
 
*[[Finding the Mode of Numbers]]
 
*[[Finding the Mode of Numbers]]

Revision as of 03:53, 21 March 2018

The median of a set of five numbers.

本教程將解釋如何找到數字的中位數。一組數字的中位數是中間值。如果這組數字是偶數個,則中位數是兩個中間數字的平均值。欲了解更多信息, 請參維基百科.

對值進行排序

Main article: Sorting Values

找到中位數的第一步是將數據從最小到最大排序。首先這樣做會使這個發現的中位數容易得多。

查找中位數

首先,按大小 排序 .

一旦這些值被排序,使用下面的腳本來獲得中位數。請記住,「列表甲」 列表包含一組數字值。該變量 「中數1」和「中數1」表示將用於存放中位值的兩個變量。


变量 [中数1 v] 设为 (链表第 ((length of [列表甲 v] :: list) / (2)) 项项目\( [列表甲 v] \) :: list)
变量 [中数2 v] 设为 (链表第 (((length of [列表甲 v] :: list) / (2)) + (1)) 项项目\( [列表甲 v] \) :: list)
如果 <((length of [列表甲 v] :: list) mod (2)) = (0)> 那么 
  说出 (字串组合 [中数值=] 和 (((中数1) + (中数2)) / (2))) (2) 秒
否则
  说出 (字串组合 [中数值=] 和 (链表第 (((length of [列表甲 v] :: list) / (2)) + (0.5)) 项项目\( [列表甲 v] \) :: list)) (2) 秒
end

相關連結