ISADORE NABI





Science and Its Philosophy From a Marxist Perspective
CÓDIGO EN R
conjunto <- c(1:10) #Puede ser cualquier conjunto
CÓDIGO EN R
length(conjunto)*length(conjunto)
prod_cart <- expand.grid(conjunto, conjunto)
CÓDIGO EN R
2^10
library(rje)
c_potencia <- powerSet(conjunto)
CÓDIGO EN R
perm_sin_rep = function(n, x) {
factorial(n) / factorial(n-x)
}
cantidad_perm_sin_rep <- 0
for(i in 1:10){
temp <- perm_sin_rep(10, i)
cantidad_perm_sin_rep <- cantidad_perm_sin_rep + temp
}
library(gtools)
permutaciones_sinrep <- list(permutations(10, 1, conjunto), permutations(10, 2, conjunto),
permutations(10, 3, conjunto), permutations(10, 4, conjunto),
permutations(10, 5, conjunto), permutations(10, 6, conjunto),
permutations(10, 7, conjunto), permutations(10, 8, conjunto),
permutations(10, 9, conjunto), permutations(10, 10, conjunto))
CÓDIGO EN R
library(gtools)
permutations(10, 10, conjunto, set = FALSE)
CÓDIGO EN R
comb_sin_rep = function(n, x) {
factorial(n) / (factorial(x) * factorial(n – x)) # combinaciones sin repetición
}
cantidad_comb_sin_rep <- 0
for(i in 1:10){
temp <- comb_sin_rep(10, i)
cantidad_comb_sin_rep <- cantidad_comb_sin_rep + temp
}
library(gtools)
combinaciones_sinrep <- list(combinations(10, 1, conjunto), combinations(10, 2, conjunto),
combinations(10, 3, conjunto), combinations(10, 4, conjunto),
combinations(10, 5, conjunto), combinations(10, 6, conjunto),
combinations(10, 7, conjunto), combinations(10, 8, conjunto),
combinations(10, 9, conjunto), combinations(10, 10, conjunto))
CÓDIGO EN R
comb_con_rep = function(n, x) {
factorial(n + x – 1) / (factorial(x) * factorial(n – 1)) # combinaciones con repetición
}
cantidad_comb_con_rep <- 0
for(i in 1:10){
temp <- comb_con_rep(10, i)
cantidad_comb_con_rep <- cantidad_comb_con_rep + temp
}
combinaciones_conrep <- list(combinations(10, 1, conjunto, repeats.allowed=TRUE),
combinations(10, 2, conjunto, repeats.allowed=TRUE),
combinations(10, 3, conjunto, repeats.allowed=TRUE),
combinations(10, 4, conjunto, repeats.allowed=TRUE),
combinations(10, 5, conjunto, repeats.allowed=TRUE),
combinations(10, 6, conjunto, repeats.allowed=TRUE),
combinations(10, 7, conjunto, repeats.allowed=TRUE),
combinations(10, 8, conjunto, repeats.allowed=TRUE),
combinations(10, 9, conjunto, repeats.allowed=TRUE),
combinations(10, 10, conjunto, repeats.allowed=TRUE))