[R] Join and Meet on Lattice

From: Vahid <vahidmojtahed_at_yahoo.com>
Date: Tue, 10 May 2011 03:32:13 -0700 (PDT)


Hi,

I am using a package to calculate Join and Meet on lattice. I have written a function that generates partitions and then try to see if their meet is the power set.
When I give values to this function greater than lets say 6 (n=k=6) and delta =0 , it slows down.
I believe it is something due to commands that I use. But I can't see it. Is there any one who can help me?

vahid

#library(partitions)

library(clue)

# First clear all

rm(list=ls(all=TRUE))

# n: number of balls
# k: number of urns
# this is for the case of no difficulty
# delta shows the difference between number of urns. delta=0 shows that urns are
the same in both cases.
#

urn <- function(n,k,delta){

# trivial partitions or power set: all elements are in one partition. i.e. (1 1
1 1 1 ) for n = 5
trivial <- as.numeric(cbind(rep(1,n)))
t <- as.cl_class_ids(trivial)     

# write Trivial in the matrice form (hard partition)
# set counter and number of rounds.

counter <- 0

    rounds <- 10

for(i in 1:rounds){
x<- as.numeric(cbind(sample.int( k , n , replace = TRUE, prob = NULL))) y<- as.numeric(cbind(sample.int( k + delta , n , replace = TRUE, prob = NULL)))     

# A matrice which shows each object belongs to which class/partition. This is a
Hard partition; membership id shown by {0,1} A <- as.cl_partition(x)
B <- as.cl_partition(y)     

#join of them: The out put is a vector of the class ids
m <- cl_join(A,B)     

# check if the join of two partition is the trivial partition
if(m==t){counter<-counter+1}
}
probability <- counter/rounds

return(probability)}

        [[alternative HTML version deleted]]



R-help_at_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. Received on Tue 10 May 2011 - 12:46:32 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 13:00:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive