Re: [R] frequency of numbers
Thanks, got it. ** Bander Alzahrani, r * Date: Thu, 21 Nov 2013 09:14:11 -0600 Subject: Re: [R] frequency of numbers From: deter...@umn.edu To: cs_2...@hotmail.com CC: r-help@r-project.org If you just need a count of how many of each number you can just use table(). > tmp <- c(111,106,117,108,120,108,108,116,113) > table(tmp) tmp 106 108 111 113 116 117 120 1 3 1 1 1 1 1 On Thu, Nov 21, 2013 at 9:10 AM, b. alzahrani wrote: hi guys Assume I have this dataframe: v3$number_of_ones [1] 111 106 117 108 120 108 108 116 116 113 Is there any command in r that gives me the frequency of these numbers (how many each number is repeated e.g. the number 108 repeated 2 and 111 repeated one an so on) I have around 10^6 number and would like to see how many each number if repeated. Regards ** Bander Alzahrani, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Charles Determan Integrated Biosciences PhD Candidate University of Minnesota [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] frequency of numbers
hi guys Assume I have this dataframe: v3$number_of_ones [1] 111 106 117 108 120 108 108 116 116 113 Is there any command in r that gives me the frequency of these numbers (how many each number is repeated e.g. the number 108 repeated 2 and 111 repeated one an so on) I have around 10^6 number and would like to see how many each number if repeated. Regards ** Bander Alzahrani, [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Double Pareto Log Normal Distribution DPLN
Guys Any help in this please. Regards Bander > On 14 Nov 2013, at 09:29 pm, "David R Forrest" wrote: > > Hi Bander, > > I'm pushing this discussion back to the list, because I'm not sure of the > shape/rate parameters for rpareto and rexp and how they'd be applied across > this mix of typo'd papers. > > # Reed Equation 6 http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf > exponentiated per end of sec 3: > rdpln<-function(n,a=1,b=1,t=1,v=0){exp(v+t*rnorm(n,sd=t)+rexp(n,rate=1/a)-rexp(n,rate=1/b))} > > # Reed Equation 10: > library(VGAM) > rdpln2<-function(n,a,b,v,t){ rlnorm(n,meanlog=v,sdlog=t)* > rpareto(n,location=1,shape=1/a)/ > rpareto(n,location=1,shape=1/b)} > > boxplot(data.frame(x1= log(rdpln(a=2.5,b=.01,t=0.45,v=6.5,n=10)), x2= > log(rdpln2(a=2.5,b=.01,t=0.45,v=6.5,n=10 > > # Reed equation 8 http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf > # with S1 errata #1 from > http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0048964 > > ddpln <- function(x, a=1, b=1, v=0, t=1){ > # Density of Double Pareto LogNormal distribution > # from "b. alzahrani" email of 2013-11-13 > # per formula 8 from http://cs.stanford.edu/people/jure/pubs/dpln-kdd08.pdf > > c <- (a * b /(a+b)) > > norm1<-pnorm((log(x)-v-(a*t^2))/t) > norm2<-pnorm((log(x)-v+(b*t^2))/t) > expo1<- a*v+(a^2*t^2/2) > expo2<- -b*v+(b^2*t^2/2) # edited from the paper's eqn 8 with: s/t/v/ > > z<- (x^(-a-1)) * exp(expo1)*( norm1) > y<- (x^( b-1)) * exp(expo2)*(1-norm2) # 1-norm is the complementary CDF of > N(0,1) > > c*(z+y) > } > > > Dave > > > > On Nov 14, 2013, at 9:12 AM, David Forrest > wrote: > >> >> I think exponentiation of eqn 6 from the Reed paper generates DPLN variates >> directly, so maybe: >> >> rdpln=function(n,a=1,b=1,t=1,v=0){exp(v+t*rnorm(n,sd=t)+rexp(n,rate=1/a)-rexp(n,rate=1/b))} >> >> >> Dave >> >> >> On Nov 13, 2013, at 4:34 PM, "b. alzahrani" >> wrote: >> >>> You help is much appreciated. Just one last point if you could help, Now I >>> want to pass this curve to a function that can generate random numbers >>> distributed according to DPLN ( right curve). >>> >>> I found the package Runuran can do that >>> http://cran.r-project.org/web/packages/Runuran/Runuran.pdf but I do not >>> know how to do it I think it would be something similar to page 8 and 9. >>> >>> Regards >>> ** >>> Bander >>> * >>> >>> >>> >>> From: d...@vims.edu >>> To: cs_2...@hotmail.com >>> Subject: Re: [R] Double Pareto Log Normal Distribution DPLN >>> Date: Wed, 13 Nov 2013 21:13:43 + >>> >>> >>> I read the parameters in Fig 4, right as "DPLN[2.5,0.1,0.45,6.5]", so: >>> >>> x<- 10^seq(0,4,by=.1) >>> plot(x,ddpln(x,a=2.5,b=.01,v=6.5,t=0.45),log='xy',type='l') >>> >>> ... and the attached graph does not look dissimilar the figure--It starts >>> at 10^-2, goes through 10^-4 at x=100, and elbows down around 900 and >>> passes through 10^-6 at about 2000. >>> >>> The correction of Reed helps -- The uncorrected Reed Eq9 equation suggests >>> that the the 't' in Sehshadri Eq9 should be a 'v' , but it doesn't exactly >>> make sense with the extra 'a' in there. If the errata clears that up, then >>> your expo2 term looks just like the expo1 term, but with a=-b. >>> >>> >>> >>> >>> >>> On Nov 13, 2013, at 3:43 PM, "b. alzahrani" wrote: > Thank you very much >>> for the help and the change you suggested in my code, I also found a >>> correction on equation 9 that has been published by Reed ( here >>> http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf i.e. the original paper on >>> Double Pareto Log Normal Distribution ). > > can you please see the >>> correction in this >>> linkhttp://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0048964 >>> (in Supporting Information section, appendix S1), does your suggested code >>> coincide with the correction on this link? as I can see > > Actually, I am >>> interested in the most right curve in figure 4.
Re: [R] Double Pareto Log Normal Distribution DPLN
Thanks Dave for your help on this. Waiting other suggestions from the list on this. Regards Bander > On 14 Nov 2013, at 09:29 pm, "David R Forrest" wrote: > > Hi Bander, > > I'm pushing this discussion back to the list, because I'm not sure of the > shape/rate parameters for rpareto and rexp and how they'd be applied across > this mix of typo'd papers. > > # Reed Equation 6 http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf > exponentiated per end of sec 3: > rdpln<-function(n,a=1,b=1,t=1,v=0){exp(v+t*rnorm(n,sd=t)+rexp(n,rate=1/a)-rexp(n,rate=1/b))} > > # Reed Equation 10: > library(VGAM) > rdpln2<-function(n,a,b,v,t){ rlnorm(n,meanlog=v,sdlog=t)* > rpareto(n,location=1,shape=1/a)/ > rpareto(n,location=1,shape=1/b)} > > boxplot(data.frame(x1= log(rdpln(a=2.5,b=.01,t=0.45,v=6.5,n=10)), x2= > log(rdpln2(a=2.5,b=.01,t=0.45,v=6.5,n=10 > > # Reed equation 8 http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf > # with S1 errata #1 from > http://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0048964 > > ddpln <- function(x, a=1, b=1, v=0, t=1){ > # Density of Double Pareto LogNormal distribution > # from "b. alzahrani" email of 2013-11-13 > # per formula 8 from http://cs.stanford.edu/people/jure/pubs/dpln-kdd08.pdf > > c <- (a * b /(a+b)) > > norm1<-pnorm((log(x)-v-(a*t^2))/t) > norm2<-pnorm((log(x)-v+(b*t^2))/t) > expo1<- a*v+(a^2*t^2/2) > expo2<- -b*v+(b^2*t^2/2) # edited from the paper's eqn 8 with: s/t/v/ > > z<- (x^(-a-1)) * exp(expo1)*( norm1) > y<- (x^( b-1)) * exp(expo2)*(1-norm2) # 1-norm is the complementary CDF of > N(0,1) > > c*(z+y) > } > > > Dave > > > > On Nov 14, 2013, at 9:12 AM, David Forrest > wrote: > >> >> I think exponentiation of eqn 6 from the Reed paper generates DPLN variates >> directly, so maybe: >> >> rdpln=function(n,a=1,b=1,t=1,v=0){exp(v+t*rnorm(n,sd=t)+rexp(n,rate=1/a)-rexp(n,rate=1/b))} >> >> >> Dave >> >> >> On Nov 13, 2013, at 4:34 PM, "b. alzahrani" >> wrote: >> >>> You help is much appreciated. Just one last point if you could help, Now I >>> want to pass this curve to a function that can generate random numbers >>> distributed according to DPLN ( right curve). >>> >>> I found the package Runuran can do that >>> http://cran.r-project.org/web/packages/Runuran/Runuran.pdf but I do not >>> know how to do it I think it would be something similar to page 8 and 9. >>> >>> Regards >>> ** >>> Bander >>> * >>> >>> >>> >>> From: d...@vims.edu >>> To: cs_2...@hotmail.com >>> Subject: Re: [R] Double Pareto Log Normal Distribution DPLN >>> Date: Wed, 13 Nov 2013 21:13:43 + >>> >>> >>> I read the parameters in Fig 4, right as "DPLN[2.5,0.1,0.45,6.5]", so: >>> >>> x<- 10^seq(0,4,by=.1) >>> plot(x,ddpln(x,a=2.5,b=.01,v=6.5,t=0.45),log='xy',type='l') >>> >>> ... and the attached graph does not look dissimilar the figure--It starts >>> at 10^-2, goes through 10^-4 at x=100, and elbows down around 900 and >>> passes through 10^-6 at about 2000. >>> >>> The correction of Reed helps -- The uncorrected Reed Eq9 equation suggests >>> that the the 't' in Sehshadri Eq9 should be a 'v' , but it doesn't exactly >>> make sense with the extra 'a' in there. If the errata clears that up, then >>> your expo2 term looks just like the expo1 term, but with a=-b. >>> >>> >>> >>> >>> >>> On Nov 13, 2013, at 3:43 PM, "b. alzahrani" wrote: > Thank you very much >>> for the help and the change you suggested in my code, I also found a >>> correction on equation 9 that has been published by Reed ( here >>> http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf i.e. the original paper on >>> Double Pareto Log Normal Distribution ). > > can you please see the >>> correction in this >>> linkhttp://www.plosone.org/article/info%3Adoi%2F10.1371%2Fjournal.pone.0048964 >>> (in Supporting Information section, appendix S1), does your suggested code >>> coincide with the correction on this link? as I can see > > Actually, I am
Re: [R] Double Pareto Log Normal Distribution DPLN
Hi I found this paper http://cs.stanford.edu/people/jure/pubs/dpln-kdd08.pdf that models the DPLN distribution as in equation 8. I implemented this in R but cannot get the same curve as in Figure 4. can you please check if my code below is correct: e.g. is the use of pnorm() correct here? ddlpn <- function(x){ a=2.8 b=0.01 v=0.45 t=6.5 j <- (a * b /(a+b)) norm1<-pnorm((log(x)-v-(a*t^2))/t) expo1<- a*v+(a^2*t^2/2) z<-exp(expo1)*(x^(-a-1))*(norm1) norm2<-pnorm((log(x)-v+(b*t^2))/t) expo2<- -b*t+(b^2*t^2/2) y<- x^(b-1)*exp(expo2)*(1-norm2) # 1-norm is the complementary CDF of N(0,1) j*(z+y) } ** Bander Alzahrani, Teacher Assistant Information Systems Department Faculty of Computing & Information Technology King Abdulaziz University * > From: d...@vims.edu > To: cs_2...@hotmail.com > CC: r-h...@stat.math.ethz.ch > Subject: Re: [R] Double Pareto Log Normal Distribution > Date: Tue, 12 Nov 2013 16:51:22 + > > > http://www.math.uvic.ca/faculty/reed/dPlN.3.pdf is the original ref and has > the equations. > > library(VGAM) for *pareto() and library(stats) for *lnorm() should get you > most of the way there. > > On Nov 12, 2013, at 10:47 AM, "b. alzahrani" > wrote: > > > Hi guys > > I would like to generate random number Double Pareto Log Normal > > Distribution (DPLN). does anyone know how to do this in R or if there is > > any built-in function. > > > > Thanks > > > > ** > > Bander > > * > > > > > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > -- > Dr. David Forrest > d...@vims.edu > > > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Double Pareto Log Normal Distribution
Hi guys I would like to generate random number Double Pareto Log Normal Distribution (DPLN). does anyone know how to do this in R or if there is any built-in function. Thanks ** Bander * [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] transform one probability distribution into another
Hi guys Given a exponential curve, is there any function on r that can generate exponential distributed random numbers? in General I want an function that can transform one probability distribution into another?? Regards ** Bander * [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] AES algorithm package
Hi Is there any implementation for AES encryption algorithm in R? Thanks Bander __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.