_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › Histogram

Contents

1 shape
2 蟆轟蠏碁Μ蠍
3 hist boxplot 豢螳蠍
4 hist line 豢螳蠍
5 sigma level
6 覿(ろ蠏碁)
7 ろ讌 覦覯
8 譴ク谿襯 伎 覦覯
9 5螻 螳
10 蠍壱
11 R 伎 ろ蠏碁
12 蠏碁9覲襦
13 2D ろ蠏碁


1 shape #

library(rgr)
shape(iris$Sepal.Length, ifqs = TRUE)
shape.png

2 蟆轟蠏碁Μ蠍 #

rgb()襦 rgb(red, green, blue, alpha ..) 蟾, 覈襯 譟一.
hist(iris[iris$Species =="setosa", 1], col="grey", xlim=range(iris$Sepal.Length), ylim=c(0,25))
hist(iris[iris$Species =="versicolor", 1], col=rgb(1, 0, 0, 0.5), add=TRUE)
hist(iris[iris$Species =="virginica", 1], col=rgb(0, 1, 0, 0.5), add=TRUE)
hist_group.png

3 hist boxplot 豢螳蠍 #

hist(iris$Sepal.Length)
sfsmisc::histBxp(iris$Sepal.Length) 
hist_boxplot.png

library(packHV)
hist_boxplot(iris$Sepal.Length)
hist_boxplot2.png

4 hist line 豢螳蠍 #

覦覯: https://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_adlin.html
rescale<-function(x,newrange) {
  if(nargs() > 1 && is.numeric(x) && is.numeric(newrange)) {
    # if newrange has max first, reverse it
    if(newrange[1] > newrange[2]) {
      newmin<-newrange[2]
      newrange[2]<-newrange[1]
      newrange[1]<-newmin
    }
    xrange<-range(x)
    if(xrange[1] == xrange[2]) stop("can't rescale a constant vector!")
    mfac<-(newrange[2]-newrange[1])/(xrange[2]-xrange[1])
    invisible(newrange[1]+(x-xrange[1])*mfac)
  }
  else {
    cat("Usage: rescale(x,newrange)\n")
    cat("\twhere x is a numeric object and newrange is the min and max of the new range\n")
  }
}


set.seed(1)
val1 <- rnorm(50)

set.seed(100)
val2 <- rnorm(100) + 5

val <- c(val1, val2)

h <- hist(val)
plot(h)
lines(rescale(spline(h$counts)$x, range(h$mids)), spline(h$counts)$y)

hist_add_line.png

6 覿(ろ蠏碁) #

企 一危郁 豌 譴 谿讌 豺襯 願鍵 伎 豌 蟆渚レ 殊 襷れ 譴. 豌 蟆渚レ 磯 覿螳 襷れ . 覿 れ螻 螳 覦覯朱 襷 .

  1. 一危一 豕, 豕螳 蟲.
  2. 襭 蠍一 磯 麹 螻蠍 襯 .(伎豺 蟇壱.(伎豺 蟇 覦覯))
  3. 譴覲給讌 蟆 螻蠍 蠍磯ゼ .
  4. 螳 螻蠍 (一危 )襯 蟲.
  5. 螻蠍 一朱 .
  6. 襯 蟲. ( = 企 螻蠍 / 豌 )

7 ろ讌 覦覯 #

ろ讌れ 覦覯 糾 豈 蟇一 豌 覿覿 る 伎企. ろ讌る 螻蠍 [1]襯 蟆一 覦覯朱 れ螻 螳 螻旧 襷れ.

  • 螻蠍 k = 1 + (log10N / log102) (N; 襭 ) = 1 + (LOG10(N) / LOG10(2))
  • 螻蠍 覯 R = (Max螳 - Min螳) / k

覿襯 覦覯 螻旧 伎 れ螻 螳 襦 蟲覃 .

  1. 一危一 豐 螳, Max螳, Min螳 蟲. Max螳, Min螳 蟲 伎豺襯 蟇壱 蟆 譬.
  2. ろ讌れ 覦覯 伎 螻蠍 (k)襯 蟲.
  3. 螻 蟲伎 螻蠍 k襯 伎 螳 覯襯 蟲.
  4. 蟲伎 覯襦 一危磯ゼ 蟲覿.

れ SQL Server 2005 T-SQL 蟲 企.
DECLARE
	@k int
,	@r bigint
,	@avg  bigint
,	@sigma bigint
, 	@min bigint
,	@max bigint
,	@cnt int
, 	@min_real bigint
,	@max_real bigint

--1 + (LOG10(N) / LOG10(2))

SELECT
	@sigma = STDEV(Score)
,	@avg = AVG(Score)
,	@min_real = MIN(Score)
,	@max_real = MAX(Score)
FROM #Score

-- 伎豺 蟇壱 蟲螳 蟲.: 蠏 - (1.5 * 譴ク谿) ~ 蠏 + (1.5 * 譴ク谿)
SELECT
	@r = (MAX(Score) - MIN(Score)) / (1 + (LOG10(COUNT(*)) / LOG10(2)))
,	@k = (1 + (LOG10(COUNT(*)) / LOG10(2)))
,	@cnt = COUNT(*)
,	@min = MIN(Score)
,	@max = MAX(Score)
FROM #Score
WHERE Score > @avg - (3 * @sigma)
AND Score < @avg + (3 * @sigma)

;WITH Dumy(Seq)
AS
(
        SELECT 1 Seq
        UNION ALL
        SELECT Seq + 1 FROM Dumy
        WHERE Seq + 1 <= @k
), Grade
AS
(
	SELECT 
		(@k - Seq ) + 1 Grade
	,	@min + ((Seq-1) * @r) BeginScore
	,	@min + (Seq * @r) EndScore
	FROM Dumy
), RealGrade
AS
(
	SELECT Grade, BeginScore, EndScore FROM Grade
	UNION ALL
	SELECT Grade + 1, @min_real, EndScore + 1
	FROM Grade
	WHERE Grade = (SELECT MAX(Grade) FROM Grade)
	UNION ALL
	SELECT Grade - 1, BeginScore + 1, @max_real
	FROM Grade
	WHERE Grade = (SELECT MIN(Grade) FROM Grade)
)
SELECT
	B.Grade
,	COUNT(*) AccountCnt
,	SUM(NetAMT) NetAMT
FROM #Score A
	INNER JOIN RealGrade B
		ON A.Score BETWEEN B.BeginScore AND B.EndScore
GROUP BY
	B.Grade
ORDER BY 1


8 譴ク谿襯 伎 覦覯 #

譴ク谿襯 伎覃 一, 覲危, 豬 企蟆 3螳 蠏碁9朱 . 襯 れ, 50覈 蠍 れ れ 蠏豺螳 170Cm願, 譴ク谿螳 7Cm れ螻 螳 . ([2]: 譴ク谿, 亮[3]: 蠏)

  • 豬: 163Cm 覩碁 (亮 - )
  • 覲危: 163 ~ 177Cm (68.3%)
  • 一: 177Cm 豐螻 (亮 + )

譴ク谿 襭 轟煙 襷れ 企 讌襦 蠏覿 15.85% , 襯 企襦 豬所骸 一襯 一 襷れ . 3螳 蠏碁9 {(亮 - 3) ~ (亮 + 3)} 螻 螳 6螳 蟲螳朱 .
normal_distribution.jpg 譴蠏覿

谿瑚襦 '6蠏碁' 蠏碁 蠏碁手骸 螳 詞 危螻 . 6蠏碁 (亮 - 6) ~ (亮 + 6) 蟲螳 詞 碁.

9 5螻 螳 #

蠏覿 れ螻 螳 5螳 蟲螳朱 .

蟲覿覯(%)
E(豕螳) ~ (m - 1.5)7%
D(m - 1.5) ~ (m - 0.5)24%
C(m - 0.5) ~ (m + 0.5)38%
B(m + 0.5) ~ (m + 1.5)24%
A(m + 1.5) ~ (豕螳)7%

10 蠍壱 #

11 R 伎 ろ蠏碁 #

x <- rnorm(100)
xnm <- "蠏覿"
hist(x, labels=TRUE, main = paste("Histogram of" , xnm), xlab = xnm)
hist01.jpg

x <- rnorm(1000)
hist(x, probability=T)
lines(density(x))
hist02.jpg

12 蠏碁9覲襦 #

install.packages("sm")
library("sm")

y <- c(1,2,3)
levels(x9$lf_group) <- c("group1", "group2", "group3")
sm.density.compare(x9$frd_cnt, x9$lf_group)
legend("topright", levels(x9$lf_group), fill=2+(0:nlevels(x9$lf_group)))

library("ggplot2")
diamonds_small <- diamonds[sample(nrow(diamonds), 1000), ]
ggplot(diamonds_small, aes(depth, fill = cut)) + geom_density(alpha = 0.2) + xlim(55, 70)
hist04.png

13 2D ろ蠏碁 #

install.packages('squash')
library('squash')
attach(quakes)
hist2(depth, long)
hist03.png
----
   [1]  覈 螳襦 讓手阿 蟆瑚
   [2]  蠏碁
   [3] 
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:53

蟾 讌襯 螳螻 朱 襦 蠍 螳 企 襷 焔 蟆 蟆企. (ろ)