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(iris$Sepal.Length) sfsmisc::histBxp(iris$Sepal.Length)
library(packHV) hist_boxplot(iris$Sepal.Length)
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)
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
蟲覿 | 覯 | 覯(%) |
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% |
x <- rnorm(100) xnm <- "蠏覿" hist(x, labels=TRUE, main = paste("Histogram of" , xnm), xlab = xnm)
x <- rnorm(1000) hist(x, probability=T) lines(density(x))
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)