Latin Hypercube Samples (lhs)  1.0
R, C++, and Rcpp code to generate Latin hypercube samples
All Classes Namespaces Files Functions Variables Typedefs Macros Pages
rutils.h File Reference
#include "OACommonDefines.h"
#include "runif.h"

Go to the source code of this file.

Namespaces

 oacpp
 

Functions

void oacpp::rutils::unifperm (std::vector< int > &pi, int q, RUnif &randomClass)
 
template<class T >
void oacpp::rutils::findranks_slow_zero (const std::vector< T > &v, std::vector< int > &indx)
 
template<class T >
void oacpp::rutils::findranks_slow (const std::vector< T > &v, std::vector< int > &indx)
 
template<class T >
bool oacpp::rutils::findranksCompare (const std::pair< T, int > &first, const std::pair< T, int > &second)
 
template<class T >
void oacpp::rutils::findranks_zero (const std::vector< T > &v, std::vector< int > &rank)
 
template<class T >
void oacpp::rutils::findranks (const std::vector< T > &v, std::vector< int > &rank)
 

Detailed Description

Author
Robert Carnell

License: This file may be freely used and shared according to the original license.

Reference:

Original Header:

These programs construct and manipulate orthogonal arrays. They were prepared by

  • Art Owen
  • Department of Statistics
  • Sequoia Hall
  • Stanford CA 94305

They may be freely used and shared. This code comes with no warranty of any kind. Use it at your own risk.

I thank the Semiconductor Research Corporation and the National Science Foundation for supporting this work.

Function Documentation

◆ findranks()

template<class T >
void oacpp::rutils::findranks ( const std::vector< T > &  v,
std::vector< int > &  rank 
)

Find the rank of each vector element

Template Parameters
Tnumeric argument that can be ranked
Parameters
vthe vector to be ranked
rankthe ranks of the elements

◆ findranks_slow()

template<class T >
void oacpp::rutils::findranks_slow ( const std::vector< T > &  v,
std::vector< int > &  indx 
)

Find the rank of each vector element

Deprecated:
This algorithm is slow, but easier to verify
Template Parameters
Tnumeric argument that can be ranked
Parameters
vthe vector to be ranked
indxthe ranks of the elements

◆ findranks_slow_zero()

template<class T >
void oacpp::rutils::findranks_slow_zero ( const std::vector< T > &  v,
std::vector< int > &  indx 
)

Find the rank of each vector element (zero based)

Deprecated:
This algorithm is slow, but easier to verify
Template Parameters
Tnumeric argument that can be ranked
Parameters
vthe vector to be ranked
indxthe ranks of the elements

◆ findranks_zero()

template<class T >
void oacpp::rutils::findranks_zero ( const std::vector< T > &  v,
std::vector< int > &  rank 
)

Find the rank of each vector element (zero based)

Template Parameters
Tnumeric argument that can be ranked
Parameters
vthe vector to be ranked
rankthe ranks of the elements

◆ findranksCompare()

template<class T >
bool oacpp::rutils::findranksCompare ( const std::pair< T, int > &  first,
const std::pair< T, int > &  second 
)

Comparison operator to use in the findranks method

Parameters
firstthe first pair of arguments (value, rank)
secondthe second pair of arguments (value, rank)
Returns
true if the value in the first argument is less than the value in the second argument

◆ unifperm()

void oacpp::rutils::unifperm ( std::vector< int > &  pi,
int  q,
RUnif randomClass 
)

In S one just does rank(runif(q)). Here we want something like rank(runif(q))-1 since the symbols to be permuted are 0..q-1

Parameters
pia vector of integers to be permuted
qlength of the vector
randomClassa random number generator class