• R语言统计分布核密度图


    正态分布核密度图

    #正态分布曲线
    x1<-round(rnorm(100,mean = 80,sd=7));x1
    density(x1)
    plot(density(x1),main="正态分布核密度图")
    polygon(density(x1),col="red",border = "blue")
    rug(x1,col="brown")
    

     

    均匀分布核密度图

    #均匀分布
    x2<-round(runif(100,min=1,max=2));x2
    plot(density(x2),main="均匀分布核密度图")
    polygon(density(x2),col=2,border="red")
    rug(x2,col="brown")
    

     

    泊松分布核密度图

    #泊松分布
    x3<-round(rpois(100,lambda = 4));x3
    plot(density(x3),main = "泊松分布核密度图")
    polygon(density(x3),col=2,border = "red")
    rug(x3,col="blue")
    

     

    指数分布核密度图

    #指数分布
    x4<-round(rexp(100,rate=2));x4
    plot(density(x4),main="指数分布核密度图")
    polygon(density(x4),col=4,border = "yellow")
    rug(x4,col="red")
    

     

    T分布核密度图

    #T分布
    x5<-round(rt(1:100,df=1));x5
    plot(density(x5),main="T分布核密度图")
    polygon(density(x5),col=2,border = "blue")
    rug(x5,col="black")
    

     

    二项分布核密度图

    #二项分布
    x6<-round(rnbinom(500,mu=4,size= 100));x6
    plot(density(x6),main = "二项分布核密度图")
    polygon(density(x6),col=6,border = "red")
    rug(x6,col="black")
    

     

    几何分布核密度图

     

    #几何分布
    x7<-round(rgeom(100,prob = 0.2));x7
    plot(density(x7),main = "几何分布核密度图")
    polygon(density(x7),col=6,border = "red")
    rug(x7,col="black")
    

     

    分布核密度图

    #X2分布
    x8<-round(rchisq(100,df=1));x8
    plot(density(x8),main = "X2分布核密度图")
    polygon(density(x8),col=6,border = "red")
    rug(x8,col="black")
    

     

    F分布核密度图

    #F分布
    x9<-round(rf(100,df1=1,df2=2));x9
    plot(density(x9),main = "F分布核密度图")
    polygon(density(x9),col=6,border = "red")
    rug(x9,col="black")
    

     

    对数正态分布核密度图

    #对数正态分布
    x10<-round(rlnorm(100,meanlog = 0,sdlog = 1));x10
    plot(density(x10),main = "对数正态分布核密度图")
    polygon(density(x10),col=6,border = "red")
    rug(x10,col="black")
    

     

    gamma核密度图

    #gamma分布
    x11<-round(rgamma(100,shape=1,scale = 1));x11
    plot(density(x11),main = "gamma分布核密度图")
    polygon(density(x11),col=7,border = "red")
    rug(x11,col="black")
    

     

    超几何分布核密度图

    #超几何分布
    x12<-round(rhyper(nn=100,m=2,n=77,k=10));x12
    plot(density(x12),main = "超几何分布核密度图")
    polygon(density(x12),col=7,border = "red")
    rug(x12,col="black")
    

     

    logisitic分布核密度图

    #logisitic分布
    x13<-round(rlogis(100,location = 0,scale = 2));x13
    plot(density(x13),main = "logisitic分布核密度图")
    polygon(density(x13),col=7,border = "red")
    rug(x13,col="black")
    

     

    Weibull分布核密度图

    #Weibull分布
    x14<-round(rweibull(100,shape = 2,scale = 5));x14
    plot(density(x14),main = "Weibull分布核密度图")
    polygon(density(x14),col=7,border = "red")
    rug(x14,col="black")
    

     

    Cauchy分布核密度图

    #Cauchy分布
    x15<-round(rcauchy(100,location = 1,scale = 2));x15
    plot(density(x15),main = "Cauchy分布核密度图")
    polygon(density(x15),col=7,border = "red")
    rug(x15,col="black")
    

     

    备注:参考《R语言实战》一书中的填色代码,结合R语言帮助文档共同完成,如有转载,注明出处,仅供学习而用

  • 相关阅读:
    215. Kth Largest Element in an Array (have better solution )
    414. Third Maximum Number
    442. Find All Duplicates in an Array
    448. Find All Numbers Disappeared in an Array
    485. Max Consecutive Ones
    532. K-diff Pairs in an Array
    8. String to Integer (atoi)
    7. Reverse Integer
    [CTSC2012]熟悉的文章(广义后缀自动机+二分答案+单调队列优化DP)
    BZOJ 2119 股市的预测(后缀数组)
  • 原文地址:https://www.cnblogs.com/cxy-0902/p/12713779.html
Copyright © 2020-2023  润新知