Skip to content

Commit

Permalink
version 0.2-5
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Singmann authored and gaborcsardi committed Nov 23, 2014
1 parent f7cff8f commit 641825c
Show file tree
Hide file tree
Showing 17 changed files with 247 additions and 291 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Package: acss
Type: Package
Title: Algorithmic Complexity for Short Strings
Version: 0.2-4
Date: 2014-05-26
Version: 0.2-5
Date: 2014-11-23
Authors@R: c( person("Nicolas", "Gauvrit", role = "aut"), person("Henrik",
"Singmann", email = "singmann@gmail.com", role = c("aut", "cre")),
"Singmann", email = "singmann+acss@gmail.com", role = c("aut", "cre")),
person("Fernando", "Soler Toscano", role = "ctb"), person("Hector",
"Zenil", role = "ctb") )
Imports: zoo
Depends: R (>= 2.15.0), acss.data
Suggests: effects
Suggests: effects, lattice
Description: Main functionality is to provide the algorithmic complexity for
short strings, an approximation of the Kolmogorov Complexity of a short
string using the coding theorem method (see ?acss). The database containing
Expand All @@ -20,12 +20,12 @@ Description: Main functionality is to provide the algorithmic complexity for
also provided: entropy and change complexity.
URL: http://complexitycalculator.com/methodology.html
License: GPL (>= 2)
Packaged: 2014-05-30 18:09:25 UTC; singmann
Packaged: 2014-11-24 19:52:41 UTC; Henrik
Author: Nicolas Gauvrit [aut],
Henrik Singmann [aut, cre],
Fernando Soler Toscano [ctb],
Hector Zenil [ctb]
Maintainer: Henrik Singmann <singmann@gmail.com>
Maintainer: Henrik Singmann <singmann+acss@gmail.com>
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-06-01 08:19:31
Date/Publication: 2014-11-25 08:45:18
30 changes: 16 additions & 14 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
d14dca539e6e4b5668e4e81741a808c3 *DESCRIPTION
1aa71d7981e6d0d5520cc85c5e7cdc38 *NAMESPACE
aec952aa1b06edf4800fa5d983493d9c *R/acss.R
52f02fd749e67ea2b3570ef414fb503d *R/exp1-data.R
cd5e5752bfda57cf970b06e6ebea1a7a *R/exp2-data.R
fbbef7db23189e1f018f78a827298558 *DESCRIPTION
0380da53e2c466a96be822f38cf289b2 *NAMESPACE
31352b2bd1bb9fb7e8a1b7d9cb1acf3f *NEWS
19cf45ac3121e318c76396f1ef3d2d4e *R/acss.R
97d77524c0c7bbeb57664d0eae1cb293 *R/exp1-data.R
5e41e32c80f532b7476e05b88c9a185e *R/exp2-data.R
a7c7844f4904d99e5ae22157702f7564 *R/helper.R
beaf07a58eb9328f2114d4e9f4f13ee7 *R/matthews2013-data.R
28cfea53a675ee407bfff9d1e2b6776d *R/matthews2013-data.R
010d95530a2e6541ff55de57950d95e8 *R/standard_complexity.R
eebbfc4ed4de669337489673c0349fbd *data/exp1.rda
a310ede93c2025689fe6ff68ec1f2d47 *data/exp2.rda
a909f05c4f406f4d4e324625a1fb1136 *data/matthews2013.rda
5034b80fe49d59e2ff921e1f16121f1e *man/acss.Rd
e8488d6bf2e740a4f6885fcfbb140bcf *man/entropy.Rd
834225415c391422c16c2d6b6484fa7a *man/exp1.Rd
21776cc0988359ff0a84d259f640e2e9 *man/exp2.Rd
c015fe218e8345b722dcb309189620db *man/matthews2013.Rd
a983c00a150a929246195343716ccbc5 *man/normalize_string.Rd
80c14ac7d420e79a7fe2e8758b5ca343 *tests/testthat/test-PsychMethods.R
507d2be192b669516e1d99613c7612a5 *tests/testthat/test-acss.R
81eca84fd189cf577873c318a33c864f *inst/CITATION
2c3aebed10e7d9f413a77b46dd9a870a *man/acss.Rd
a7959e7953a8b0e8dba944799f02532e *man/entropy.Rd
0abbb650cdde15274d14eee4ba30617e *man/exp1.Rd
68cb1b18db186af1f322471925ae9474 *man/exp2.Rd
9950aeda5ddeaef32fc2b3c548eeb571 *man/matthews2013.Rd
79fd91a88c74100703eec400b3d29ffb *man/normalize_string.Rd
47dfe07e74ced81b75d584bcc894298e *tests/testthat/test-acss.R
03c18644621f0b9335e1a2554bb32bd9 *tests/testthat/test-manuscript2014.R
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by roxygen2 (4.0.2): do not edit by hand

export(acss)
export(alternations)
export(change_complexity)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version 0.2-5 (November 2014)

o added lattice to Suggests as it is not anymore loaded with effects (needed for example of Experiment 2).
21 changes: 16 additions & 5 deletions R/acss.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' ACSS complexity
#'
#' Functions to conveniently compute algorithmic complexity for short string, an approximation of the Kolmogorov Complexity of a short string using the coding theorem method.
#' Functions to obtain the algorithmic complexity for short strings, an approximation of the Kolmogorov Complexity of a short string using the coding theorem method.
#'
#' @usage acss(string, alphabet = 9)
#'
Expand All @@ -26,15 +26,23 @@
#' \item{"prob_random"}{A named vector with the posterior probabilities that for a random process given the strings and the provided prior for being produced by a random process (default is 0.5, which correspond to a prior of 1 - 0.5 = 0.5 for a detereministic process).}
#' }
#'
#' @details The algorithmic complexity is computed using the coding theorem method: For a given set of symbols in a string, all possible or a large number of random samples of Turing machines (TM) with a given number of states (e.g., 5) and number of symbols corresponding to the number of symbols in the strings were simulated until they reached a halting state or failed to end. This package accesses a database containing data on 4.5 million strings from length 1 to 12 simulated on TMs with 2, 4, 5, 6, and 9 symbols. The complexity of the string corresponds to the distribution of the halting states of the TMs.
#' @details The algorithmic complexity is computed using the coding theorem method: For a given alphabet size (number of different symbols in a string), all possible or a large number of random samples of Turing machines (TM) with a given number of states (e.g., 5) and number of symbols corresponding to the alphabet size were simulated until they reached a halting state or failed to end.
#' The outputs of the TMs at the halting states produces a distribution of strings known as the algorithmic probability of the strings. The algorithmic coding theorem (Levin, 1974) establishes the connection between the complexity of a string \eqn{K(s)} and its algorithmic probability \eqn{D(s)} as:
#' \deqn{K(s)\approx -\log_{2}(D(s))}{K(s) = log(D(s))}
#'
#' See \url{http://complexitycalculator.com/methodology.html} for more information or references below.
#' This package accesses a database containing data on 4.5 million strings from length 1 to 12 simulated on TMs with 2, 4, 5, 6, and 9 symbols.
#'
#' For a more detailed discussion see Gauvrit, Singmann, Soler-Toscano, and Zenil (2014), \url{http://complexitycalculator.com/methodology.html}, or references below.
#'
#' @references Delahaye, J.-P., & Zenil, H. (2012). Numerical evaluation of algorithmic complexity for short strings: A glance into the innermost structure of randomness. \emph{Applied Mathematics and Computation}, 219(1), 63-77. doi:10.1016/j.amc.2011.10.006
#'
#' Gauvrit, N., Zenil, H., Delahaye, J.-P., & Soler-Toscano, F. (2014). Algorithmic complexity for short binary strings applied to psychology: a primer. \emph{Behavior Research Methods}. doi:10.3758/s13428-013-0416-0
#' Gauvrit, N., Singmann, H., Soler-Toscano, F., & Zenil, H. (2014). Algorithmic complexity for psychology: A user-friendly implementation of the coding theorem method. arXiv:1409.4080 [cs, stat]. \url{http://arxiv.org/abs/1409.4080}.
#'
#' Gauvrit, N., Zenil, H., Delahaye, J.-P., & Soler-Toscano, F. (2014). Algorithmic complexity for short binary strings applied to psychology: a primer. \emph{Behavior Research Methods}, 46(3), 732-744. doi:10.3758/s13428-013-0416-0
#'
#' Levin, L. A. (1974). Laws of information conservation (nongrowth) and aspects of the foundation of probability theory. \emph{Problemy Peredachi Informatsii}, 10(3), 30-35.
#'
#' Soler-Toscano, F., Zenil, H., Delahaye, J.-P., & Gauvrit, N. (2012). \emph{Calculating Kolmogorov Complexity from the Output Frequency Distributions of Small Turing Machines}. arXiv:1211.1302 [cs.it].
#' Soler-Toscano, F., Zenil, H., Delahaye, J.-P., & Gauvrit, N. (2012). Calculating Kolmogorov Complexity from the Output Frequency Distributions of Small Turing Machines. \emph{PLoS ONE}, 9(5): e96223.
#'
#' @note The first time per session one of the functions described here is used, a relatively large dataset is loaded into memory which can take a considerable amount of time (> 10 seconds).
#'
Expand All @@ -55,6 +63,7 @@ acss <- function(string, alphabet = 9) { #, return = "matrix") {
string <- normalize_string(string)
if (is.null(alphabet)) tmp <- acss_data[string,]
else {
alphabet <- as.numeric(alphabet)
if (any(!(alphabet %in% c(2, 4, 5, 6, 9)))) stop("alphabet must be in c(2, 4, 5, 6, 9)")
tmp <- acss_data[string, paste("K", alphabet , sep = "."), drop = FALSE]
}
Expand All @@ -74,6 +83,7 @@ acss <- function(string, alphabet = 9) { #, return = "matrix") {

likelihood_d <- function(string, alphabet = 9) {
if (length(alphabet) > 1) stop("'alphabet' needs to be of length 1.")
alphabet <- as.numeric(alphabet)
if (!(alphabet %in% c(2, 4, 5, 6, 9))) stop("alphabet must be in c(2, 4, 5, 6, 9)")
check_string(string)
l <- nchar(string)
Expand Down Expand Up @@ -116,6 +126,7 @@ prob_random <- function(string, alphabet = 9, prior= 0.5){
local_complexity <- function(string, alphabet = 9, span = 5) {
check_string(string)
if (length(alphabet) > 1) stop("'alphabet' needs to be of length 1.")
alphabet <- as.numeric(alphabet)
if (!(alphabet %in% c(2, 4, 5, 6, 9))) stop("alphabet must be in c(2, 4, 5, 6, 9)")
if (span < 2 | span > 12) stop("span needs to be between 2 and 12 (inclusive).")
#browser()
Expand Down
28 changes: 14 additions & 14 deletions R/exp1-data.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Data from Experiment 1 in Gauvrit, Singmann, Soler-Toscano & Zenil
#'
#' 34 participants were asked to produce at their own pace a series of 10 symbols among "A", "B", "C", and "D" that would "look as random as possible, so that if someone else sees the sequence, she will believe it is a truly random one".
#'
#' @docType data
#' @keywords dataset
#' @name exp1
#' @usage exp1
#' @format A data.frame with 34 rows and 2 variables.
#' @source Gauvrit, Singmann, Soler-Toscano & Zenil (submitted). Complexity for psychology. A user-friendly implementation of the coding theorem method.
#'
#' @example examples/examples.exp1.R
#'
NULL
#' Data from Experiment 1 in Gauvrit, Singmann, Soler-Toscano & Zenil
#'
#' 34 participants were asked to produce at their own pace a series of 10 symbols among "A", "B", "C", and "D" that would "look as random as possible, so that if someone else sees the sequence, she will believe it is a truly random one".
#'
#' @docType data
#' @keywords dataset
#' @name exp1
#' @usage exp1
#' @format A data.frame with 34 rows and 2 variables.
#' @source Gauvrit, Singmann, Soler-Toscano & Zenil (submitted). Complexity for psychology. A user-friendly implementation of the coding theorem method.
#'
#' @example examples/examples.exp1.R
#'
NULL
32 changes: 16 additions & 16 deletions R/exp2-data.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#' Data from Experiment 2 in Gauvrit, Singmann, Soler-Toscano & Zenil
#'
#' Responses of one participant (42 years old) to 200 randomly generated strings of length 10 from an alphabet of 6 symbols.
#' For each string, the participant was asked to indicate whther or not the string appears random or not.
#'
#' @docType data
#' @keywords dataset
#' @name exp2
#' @usage exp2
#' @format A data.frame with 200 rows and 2 variables.
#' @source Gauvrit, Singmann, Soler-Toscano & Zenil (submitted). Complexity for psychology. A user-friendly implementation of the coding theorem method.
#'
#' @example examples/examples.exp2.R
#'
#'
NULL
#' Data from Experiment 2 in Gauvrit, Singmann, Soler-Toscano & Zenil
#'
#' Responses of one participant (42 years old) to 200 randomly generated strings of length 10 from an alphabet of 6 symbols.
#' For each string, the participant was asked to indicate whther or not the string appears random or not.
#'
#' @docType data
#' @keywords dataset
#' @name exp2
#' @usage exp2
#' @format A data.frame with 200 rows and 2 variables.
#' @source Gauvrit, Singmann, Soler-Toscano & Zenil (submitted). Complexity for psychology. A user-friendly implementation of the coding theorem method.
#'
#' @example examples/examples.exp2.R
#'
#'
NULL
30 changes: 15 additions & 15 deletions R/matthews2013-data.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' Data from Experiment 1 in Matthews (2013)
#'
#' Mean responses on a 6-point scale ("definitely random" to "definitely not random") of participants to 216 strings of length 21.
#'
#' @docType data
#' @keywords dataset
#' @name matthews2013
#' @usage matthews2013
#' @format A data.frame with 216 rows and 3 variables.
#' @source Matthews, W. (2013). Relatively random: Context effects on perceived randomness and predicted outcomes. \emph{Journal of Experimental Psychology: Learning, Memory, and Cognition}, 39(5), 1642-1648.
#'
#' @example examples/examples.matthews2013.R
#'
#'
NULL
#' Data from Experiment 1 in Matthews (2013)
#'
#' Mean responses on a 6-point scale ("definitely random" to "definitely not random") of participants to 216 strings of length 21.
#'
#' @docType data
#' @keywords dataset
#' @name matthews2013
#' @usage matthews2013
#' @format A data.frame with 216 rows and 3 variables.
#' @source Matthews, W. (2013). Relatively random: Context effects on perceived randomness and predicted outcomes. \emph{Journal of Experimental Psychology: Learning, Memory, and Cognition}, 39(5), 1642-1648.
#'
#' @example examples/examples.matthews2013.R
#'
#'
NULL
20 changes: 20 additions & 0 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
citHeader("To cite acss in publications use:")

citEntry(entry = "Article",
title = "Algorithmic complexity for psychology: {A} user-friendly implementation
of the coding theorem method",
author = personList(
as.person("Nicolas Gauvrit"),
as.person("Henrik Singmann"),
as.person("Fernando Soler-Toscano"),
as.person("Hector Zenil")
),
journal = "arXiv",
year = "2014",
volume = "abs/1409.4080",
url = "http://arxiv.org/abs/1409.4080",

textVersion =
paste("Gauvrit, N., Singmann, H., Soler-Toscano, F., & Zenil, H. (2014). Algorithmic complexity for psychology. A user-friendly implementation of the coding theorem method. arXiv:1409.4080")
)

Loading

0 comments on commit 641825c

Please sign in to comment.