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


***************** The code:

#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@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.

Reply via email to