UQTk: Uncertainty Quantification Toolkit 3.1.5
combin.cpp File Reference

Tools to evaluate combinatorial quantities. More...

#include "Array1D.h"
#include "Array2D.h"
#include "gen_defs.h"
#include "probability.h"
#include "combin.h"
#include <math.h>
#include <float.h>
#include "error_handlers.h"

Macros

#define STOP   1.0e-8
 
#define TINY   1.0e-30
 

Functions

int choose (int n, int k)
 Calculates binomial coefficient C(n,k): n-choose-k.
 
int factorial (int number)
 Calculates the factorial of a number.
 
double logfactorial (int number)
 Calculates the logfactorial of a number.
 
void chooseComb (int n, int k, Array2D< int > &fullInd)
 Computes all possible k-combinations of the first n non-negative integers and returns them in fullInd.
 
void get_perm (Array1D< int > &perm, int seed)
 Computes a random permutation of the first n non-negative integers and returns is in perm.
 
void get_perm (int nn, int *perm, int seed)
 Computes a random permutation of the first n non-negative integers and returns is in perm

 
double gammai (const double p, const double x)
 Compute the incomplete Gamma function with parameter a at point x.
 
double beta (const double z, const double w)
 Compute the Beta function at the point pair (z,w)
 
double betai (double a, double b, double x)
 Compute the incomplete Beta function with parameters a and b at point x.
 
double digama (double x)
 Computes the digamma, or psi, function, i.e. derivative of the logarithm of gamma function.
 
void clust (Array2D< double > &data_in, Array1D< double > &w, int ncl, Array1D< int > &numData, int *pClusterIndex)
 K-center clustering of data.
 
double clust_best (Array2D< double > &data_in, Array1D< double > &w, int ncl, Array1D< int > &bestnumData, int *bestClusterIndex, int ntry)
 Multiple trials of K-center clustering and picking the best one according to explained variance criterion.
 
int findNumCl (Array2D< double > &data_in, Array1D< double > &w, int ntry)
 Find the best number of clusters in a dataset according to one of three (hardcoded) criteria.
 

Detailed Description

Tools to evaluate combinatorial quantities.

Macro Definition Documentation

◆ STOP

#define STOP   1.0e-8

◆ TINY

#define TINY   1.0e-30

Function Documentation

◆ beta()

double beta ( const double z,
const double w )

Compute the Beta function at the point pair (z,w)

◆ betai()

double betai ( const double p,
const double q,
const double x )

Compute the incomplete Beta function with parameters a and b at point x.

Note
This is a slightly modified version of a code distributed by John Burkardt
see http://people.sc.fsu.edu/~jburkardt/cpp_src/asa063/asa063.html
see comments under the function file

◆ choose()

int choose ( int n,
int k )

Calculates binomial coefficient C(n,k): n-choose-k.

◆ chooseComb()

void chooseComb ( int n,
int k,
Array2D< int > & fullInd )

Computes all possible k-combinations of the first n non-negative integers and returns them in fullInd.

◆ clust()

void clust ( Array2D< double > & data_in,
Array1D< double > & w,
int ncl,
Array1D< int > & numData,
int * pClusterIndex )

K-center clustering of data.

Parameters
[in]data_in: Nxd matrix of data
[in]w: Array of size d; dimension-wise scaling weights
[in]ncl: Number of clusters
[out]numData: Array of size ncl; stores the number of elements for each cluster
[out]pClusterIndex: Array of size N indicating the cluster index for each data point

◆ clust_best()

double clust_best ( Array2D< double > & data_in,
Array1D< double > & w,
int ncl,
Array1D< int > & bestnumData,
int * bestClusterIndex,
int ntry )

Multiple trials of K-center clustering and picking the best one according to explained variance criterion.

◆ digama()

double digama ( double x)

Computes the digamma, or psi, function, i.e. derivative of the logarithm of gamma function.

Note
This is a slightly modified version of a code distributed by John Burkardt
see http://people.sc.fsu.edu/~jburkardt/cpp_src/asa103/asa103.cpp

◆ factorial()

int factorial ( int number)

Calculates the factorial of a number.

◆ findNumCl()

int findNumCl ( Array2D< double > & data_in,
Array1D< double > & w,
int ntry )

Find the best number of clusters in a dataset according to one of three (hardcoded) criteria.

◆ gammai()

double gammai ( const double a,
const double x )

Compute the incomplete Gamma function with parameter a at point x.

Note
This is a slightly modified version of a code distributed by John Burkardt
see http://people.sc.fsu.edu/~jburkardt/cpp_src/asa147/asa147.html
see comments under the function definition

◆ get_perm() [1/2]

void get_perm ( Array1D< int > & perm,
int seed )

Computes a random permutation of the first n non-negative integers and returns is in perm.

Note
n is the size of the array argument perm

◆ get_perm() [2/2]

void get_perm ( int nn,
int * perm,
int seed )

Computes a random permutation of the first n non-negative integers and returns is in perm

◆ logfactorial()

double logfactorial ( int number)

Calculates the logfactorial of a number.