Liking cljdoc? Tell your friends :D

incanter.distributions

Probability functions (pdf, cdf, draw, etc.) for common distributions, and for collections, sets, and maps.

Probability functions (pdf, cdf, draw, etc.) for common distributions, and for collections, sets, and maps.
raw docstring

*test-statistic-iterations*clj

source

*test-statistic-map*clj

source

beta-distributionclj

(beta-distribution)
(beta-distribution alpha beta)

Returns a Beta distribution that implements the incanter.distributions.Distribution protocol.

Arguments: alpha (default 1) beta (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Beta.html http://en.wikipedia.org/wiki/Beta_distribution

Example: (pdf (beta-distribution 1 2) 0.5)

Returns a Beta distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  alpha      (default 1)
  beta       (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Beta.html
  http://en.wikipedia.org/wiki/Beta_distribution

Example:
  (pdf (beta-distribution 1 2) 0.5)
sourceraw docstring

binomial-distributionclj

(binomial-distribution)
(binomial-distribution n p)

Returns a Binomial distribution that implements the incanter.distributions.Distribution protocol.

Arguments: size (default 1) prob (default 1/2)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.html http://en.wikipedia.org/wiki/Binomial_distribution

Example: (pdf (binomial-distribution 20 1/4) 10)

Returns a Binomial distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  size       (default 1)
  prob       (default 1/2)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.html
  http://en.wikipedia.org/wiki/Binomial_distribution

Example:
  (pdf (binomial-distribution 20 1/4) 10)
sourceraw docstring

chisq-distributionclj

(chisq-distribution)
(chisq-distribution df)

Returns a Chi-square distribution that implements the incanter.distributions.Distribution protocol.

Arguments: df (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/ChiSquare.html http://en.wikipedia.org/wiki/Chi_square_distribution

Example: (pdf (chisq-distribution 2) 5.0)

Returns a Chi-square distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  df         (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/ChiSquare.html
  http://en.wikipedia.org/wiki/Chi_square_distribution

Example:
  (pdf (chisq-distribution 2) 5.0)
sourceraw docstring

colt-extendersclj

source

combination-distributionclj

(combination-distribution n k)

Create a distribution of all the k-sized combinations of n integers. Can be considered a multivariate distribution over k-dimensions, where each dimension is a discrete random variable on the (0, n] range (though these variables are decidedly non-independent).

A draw from this distribution can also be considered a sample without replacement from any finite set, where the values in the returned vector represent the indices of the items in the set.

Arguments: n The number of possible items from which to select. k The size of a sample (without replacement) to draw.

See also: test-statistic-distribution, integer-distribution, pdf, cdf, draw, support

References: http://en.wikipedia.org/wiki/Combination

Create a distribution of all the k-sized combinations of n integers.
Can be considered a multivariate distribution over k-dimensions, where
each dimension is a discrete random variable on the (0, n] range (though
these variables are decidedly non-independent).

A draw from this distribution can also be considered a sample without
replacement from any finite set, where the values in the returned
vector represent the indices of the items in the set.

Arguments:
  n	  The number of possible items from which to select.
  k	  The size of a sample (without replacement) to draw.

See also:
  test-statistic-distribution, integer-distribution, pdf, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/Combination

sourceraw docstring

Distributioncljprotocol

The distribution protocol defines operations on probability distributions. Distributions may be univariate (defined over scalars) or multivariate (defined over vectors). Distributions may be discrete or continuous.

For a list of types that implement the protocol run (extenders Distribution). Implementations are provided for the various Clojure collection datatypes. See the example below for using the distribution methods on these types.

See also: pdf, cdf, draw, support

References: http://en.wikipedia.org/wiki/Probability_distribution

Examples: (support [1 3 4 2 1 3 4 2]) ; returns the set #{1 2 3 4} (draw [1 3 4 2 1 3 4 2]) ; returns a value from #{1 2 3 4} (pdf [2 1 2] 1) ; returns the value 1/3 (cdf [2 1 2 3] 2) ; returns the value 3/4

The distribution protocol defines operations on probability distributions.
Distributions may be univariate (defined over scalars) or multivariate
(defined over vectors). Distributions may be discrete or continuous.

For a list of types that implement the protocol run (extenders Distribution).
Implementations are provided for the various Clojure collection datatypes.
See the example below for using the distribution methods on these types.

See also:
  pdf, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/Probability_distribution

Examples:
  (support [1 3 4 2 1 3 4 2]) ; returns the set #{1 2 3 4}
  (draw [1 3 4 2 1 3 4 2]) ; returns a value from #{1 2 3 4}
  (pdf [2 1 2] 1) ; returns the value 1/3
(cdf [2 1 2 3] 2) ; returns the value 3/4

cdfclj

(cdf d v)

A function of the incanter.distribution.Distribution protocol.

Returns the value of the cumulative density function for the distribution d at support v.

See also: Distribution, pdf, draw, support

References: http://en.wikipedia.org/wiki/Cumulative_distribution_function

Examples: (cdf [2 1 2 3] 2) ; returns the value 3/4

A function of the incanter.distribution.Distribution protocol.

Returns the value of the cumulative density function for the
distribution d at support v.

See also:
  Distribution, pdf, draw, support

References:
  http://en.wikipedia.org/wiki/Cumulative_distribution_function

Examples:
  (cdf [2 1 2 3] 2) ; returns the value 3/4 

drawclj

(draw d)

A function of the incanter.distribution.Distribution protocol.

Returns a randomly drawn value from the support of distribution d.

See also: Distribution, pdf, cdf, support

Examples: (draw [1 3 4 2 1 3 4 2]) ; returns a value from #{1 2 3 4}

A function of the incanter.distribution.Distribution protocol.

Returns a randomly drawn value from the support of distribution d.

See also:
  Distribution, pdf, cdf, support

Examples:
  (draw [1 3 4 2 1 3 4 2]) ; returns a value from #{1 2 3 4}

meanclj

(mean d)

mean

mean

pdfclj

(pdf d v)

A function of the incanter.distribution.Distribution protocol.

Returns the value of the probability density/mass function for the distribution d at support v.

See also: Distribution, cdf, draw, support

References: http://en.wikipedia.org/wiki/Probability_density_function

Examples: (pdf [2 1 2] 1) ; returns the value 1/3

A function of the incanter.distribution.Distribution protocol.

Returns the value of the probability density/mass function for the
distribution d at support v.

See also:
  Distribution, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/Probability_density_function

Examples:
  (pdf [2 1 2] 1) ; returns the value 1/3

supportclj

(support d)

**** EXPERIMENTAL **** A function of the incanter.distribution.Distribution protocol.

Returns the support of the probability distribution d. For discrete distributions, the support is a set (i.e. #{1 2 3}). For continuous distributions, the support is a 2 element vector describing the range. For example, the uniform distribution over the unit interval would return the vector [0 1].

This function is marked as experimental to note that the output format might need to adapt to more complex support structures. For example, what would best describe a mixture of continuous distributions?

See also: Distribution, pdf, draw, support

References: http://en.wikipedia.org/wiki/Cumulative_distribution_function

Examples: (cdf [2 1 2 3] 2) ; returns the value 3/4

**** EXPERIMENTAL ****
A function of the incanter.distribution.Distribution protocol.

Returns the support of the probability distribution d.
For discrete distributions, the support is a set (i.e. #{1 2 3}).
For continuous distributions, the support is a 2 element vector
describing the range. For example, the uniform distribution over
the unit interval would return the vector [0 1].

This function is marked as experimental to note that the output
format might need to adapt to more complex support structures.
For example, what would best describe a mixture of continuous
distributions?

See also:
  Distribution, pdf, draw, support

References:
  http://en.wikipedia.org/wiki/Cumulative_distribution_function

Examples:
  (cdf [2 1 2 3] 2) ; returns the value 3/4 

varianceclj

(variance d)

variance

variance
sourceraw docstring

exponential-distributionclj

(exponential-distribution)
(exponential-distribution rate)

Returns a Exponential distribution that implements the incanter.distributions.Distribution protocol.

Arguments: rate (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.html http://en.wikipedia.org/wiki/Exponential_distribution

Example: (pdf (exponential-distribution 1/2) 2.0)

Returns a Exponential distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  rate       (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.html
  http://en.wikipedia.org/wiki/Exponential_distribution

Example:
  (pdf (exponential-distribution 1/2) 2.0)
sourceraw docstring

f-distributionclj

(f-distribution)
(f-distribution df1 df2)

Returns a F-distribution that implements the incanter.distributions.Distribution protocol.

Arguments: df1 (default 1) df2 (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://en.wikipedia.org/wiki/F_distribution http://mathworld.wolfram.com/F-Distribution.html

Example: (pdf (f-distribution 5 2) 1.0)

Returns a F-distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  df1        (default 1)
  df2        (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/F_distribution
  http://mathworld.wolfram.com/F-Distribution.html

Example:
  (pdf (f-distribution 5 2) 1.0)
sourceraw docstring

gamma-distributionclj

(gamma-distribution)
(gamma-distribution shape scale)

Returns a Gamma distribution that implements the incanter.distributions.Distribution protocol.

Arguments: shape (k) (default 1) scale (θ) (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Gamma.html http://en.wikipedia.org/wiki/Gamma_distribution

Example: (pdf (gamma-distribution 1 2) 10)

Returns a Gamma distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  shape (k)  (default 1)
  scale (θ)  (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Gamma.html
  http://en.wikipedia.org/wiki/Gamma_distribution

Example:
  (pdf (gamma-distribution 1 2) 10)
sourceraw docstring

inf+clj

source

inf-clj

source

integer-distributionclj

(integer-distribution)
(integer-distribution end)
(integer-distribution start end)

Create a uniform distribution over a set of integers over the (start, end] interval. An alternative method of creating a distribution would be to just use a sequence of integers (e.g. (draw (range 100000))). For large sequences, like the one in the example, using a sequence will be require realizing the entire sequence before a draw can be taken. This less efficient than computing random draws based on the end points of the distribution.

Arguments: start The lowest end of the interval, such that (>= (draw d) start) is always true. (Default 0) end The value at the upper end of the interval, such that (> end (draw d)) is always true. Note the strict inequality. (Default 1)

See also: pdf, cdf, draw, support

References: http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)

Examples: (pdf (integer-distribution 0 10) 3) ; returns 1/10 for any value (draw (integer-distribution -5 5)) (draw (integer-distribution (bit-shift-left 2 1000))) ; probably a very large value

Create a uniform distribution over a set of integers over
the (start, end] interval. An alternative method of creating
a distribution would be to just use a sequence of integers
(e.g. (draw (range 100000))). For large sequences, like the one
in the example, using a sequence will be require realizing the
entire sequence before a draw can be taken. This less efficient than
computing random draws based on the end points of the distribution.

Arguments:
start	The lowest end of the interval, such that (>= (draw d) start)
      is always true. (Default 0)
  end	The value at the upper end of the interval, such that
        (> end (draw d)) is always true. Note the strict inequality.
        (Default 1)

See also:
  pdf, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/Uniform_distribution_(discrete)

Examples:
  (pdf (integer-distribution 0 10) 3) ; returns 1/10 for any value
  (draw (integer-distribution -5 5))
  (draw (integer-distribution (bit-shift-left 2 1000))) ; probably a very large value
sourceraw docstring

neg-binomial-distributionclj

(neg-binomial-distribution)
(neg-binomial-distribution size prob)

Returns a Negative binomial distribution that implements the incanter.distributions.Distribution protocol.

Arguments: size (default 10) prob (default 1/2)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.html http://en.wikipedia.org/wiki/Negative_binomial_distribution

Example: (pdf (neg-binomial-distribution 20 1/2) 10)

Returns a Negative binomial distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  size       (default 10)
  prob       (default 1/2)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.html
  http://en.wikipedia.org/wiki/Negative_binomial_distribution

Example:
  (pdf (neg-binomial-distribution 20 1/2) 10)
sourceraw docstring

next-rawclj

(next-raw rng)

Wrapper fn to pull the next raw value from an cern.jet.random.tdouble.engine.DoubleMersenneTwister prng and other engines.

Wrapper fn to pull the next raw value from an
cern.jet.random.tdouble.engine.DoubleMersenneTwister
prng and other engines.
sourceraw docstring

normal-distributionclj

(normal-distribution)
(normal-distribution mean sd)

Returns a Normal distribution that implements the incanter.distributions.Distribution protocol.

Arguments: mean The mean of the distribution. One of two parameters that summarize the Normal distribution (default 0). sd The standard deviation of the distribution. The second parameter that describes the Normal (default 1).

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Normal.html http://en.wikipedia.org/wiki/Normal_distribution

Example: (pdf (normal-distribution -2 (sqrt 0.5)) 1.96)

Returns a Normal distribution that implements the
incanter.distributions.Distribution protocol.

Arguments:
  mean	The mean of the distribution. One of two parameters
        that summarize the Normal distribution (default 0).
  sd    The standard deviation of the distribution.
        The second parameter that describes the Normal (default 1).

See also:
    Distribution, pdf, cdf, draw, support

References:
    http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Normal.html
    http://en.wikipedia.org/wiki/Normal_distribution

Example:
    (pdf (normal-distribution -2 (sqrt 0.5)) 1.96)
sourceraw docstring

poisson-distributionclj

(poisson-distribution)
(poisson-distribution lambda)

Returns a Poisson distribution that implements the incanter.distributions.Distribution protocol.

Arguments: lambda (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.html http://en.wikipedia.org/wiki/Poisson_distribution

Example: (pdf (poisson-distribution 10) 5)

Returns a Poisson distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  lambda     (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.html
  http://en.wikipedia.org/wiki/Poisson_distribution

Example:
  (pdf (poisson-distribution 10) 5)
sourceraw docstring

roulette-wheelclj

(roulette-wheel freqs)

Perform a roulette wheel selection given a list of frequencies

Perform a roulette wheel selection given a list of frequencies
sourceraw docstring

t-distributionclj

(t-distribution)
(t-distribution df)

Returns a Student-t distribution that implements the incanter.distributions.Distribution protocol.

Arguments: df (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/StudentT.html http://en.wikipedia.org/wiki/Student-t_distribution

Example: (pdf (t-distribution 10) 1.2)

Returns a Student-t distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  df         (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/StudentT.html
  http://en.wikipedia.org/wiki/Student-t_distribution

Example:
  (pdf (t-distribution 10) 1.2)
sourceraw docstring

test-statistic-distributionclj

(test-statistic-distribution test-statistic n k)

Create a distribution of the test-statistic over the possible random samples of treatment units from the possible units.

There are two methods for generating the distribution. The first method is enumerating all possible randomizations and performing the test statistic on each. This gives the exact distribution, but is only feasible for small problems.

The second method uses a combination-distribution to sample for the space of possible treatment assignments and applies the test statistic the sampled randomizations. While the resulting distribution is not exact, it is tractable for larger problems.

The algorithm automatically chooses between the two methods by computing the number of possible randomizations and comparing it to test-statistic-iterations. If the exact distribution requires fewer than test-statistic-iterations the enumeration method is used. Otherwise, it draws test-statistic-iterations total samples for the simulated method.

By default, the algorithm uses parallel computation. This is controlled by the function test-statistic-map, which is bound to pmap by default. Bind it to map to use a single thread for computation.

Arguments: test-statistic A function that takes two vectors and summarizes the difference between them n The number of total units in the pool k The number of treatment units per sample

See also: combination-distribution, pdf, cdf, draw, support

References: http://en.wikipedia.org/wiki/Sampling_distribution http://en.wikipedia.org/wiki/Exact_test http://en.wikipedia.org/wiki/Randomization_test http://en.wikipedia.org/wiki/Lady_tasting_tea

Create a distribution of the test-statistic over the possible
random samples of treatment units from the possible units.

There are two methods for generating the distribution. The
first method is enumerating all possible randomizations and
performing the test statistic on each. This gives the exact
distribution, but is only feasible for small problems.

The second method uses a combination-distribution to sample
for the space of possible treatment assignments and applies
the test statistic the sampled randomizations. While the
resulting distribution is not exact, it is tractable for
larger problems.

The algorithm automatically chooses between the two methods
by computing the number of possible randomizations and
comparing it to *test-statistic-iterations*. If the exact
distribution requires fewer than *test-statistic-iterations*
the enumeration method is used. Otherwise, it draws
*test-statistic-iterations* total samples for the simulated
method.

By default, the algorithm uses parallel computation. This is
controlled by the function *test-statistic-map*, which is
bound to pmap by default. Bind it to map to use a single
thread for computation.

Arguments:
  test-statistic	A function that takes two vectors and summarizes
      the difference between them
  n	  The number of total units in the pool
  k	  The number of treatment units per sample

See also:
  combination-distribution, pdf, cdf, draw, support

References:
  http://en.wikipedia.org/wiki/Sampling_distribution
  http://en.wikipedia.org/wiki/Exact_test
  http://en.wikipedia.org/wiki/Randomization_test
  http://en.wikipedia.org/wiki/Lady_tasting_tea

sourceraw docstring

uniform-distributionclj

(uniform-distribution)
(uniform-distribution min max)

Returns a Uniform distribution that implements the incanter.distributions.Distribution protocol.

Arguments: min (default 0) max (default 1)

See also: Distribution, pdf, cdf, draw, support

References: http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/DoubleUniform.html http://en.wikipedia.org/wiki/Uniform_distribution

Example: (pdf (uniform-distribution 1.0 10.0) 5)

Returns a Uniform distribution that implements the incanter.distributions.Distribution protocol.

Arguments:
  min        (default 0)
  max        (default 1)

See also:
  Distribution, pdf, cdf, draw, support

References:
  http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/DoubleUniform.html
  http://en.wikipedia.org/wiki/Uniform_distribution

Example:
  (pdf (uniform-distribution 1.0 10.0) 5)
sourceraw docstring

weibull-distributionclj

(weibull-distribution scale shape)
(weibull-distribution scale shape rng)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close