ITK/Examples/Utilities/MersenneTwisterRandomVariateGenerator

From KitwarePublic
< ITK‎ | Examples
Revision as of 18:51, 24 February 2011 by Daviddoria (talk | contribs) (Created page with "==MersenneTwisterRandomVariateGenerator.cxx== <source lang="cpp"> #include "itkMersenneTwisterRandomVariateGenerator.h" void UniformDouble(); void Int(); int main(int, char*[])...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

MersenneTwisterRandomVariateGenerator.cxx

<source lang="cpp">

  1. include "itkMersenneTwisterRandomVariateGenerator.h"

void UniformDouble(); void Int();

int main(int, char*[]) {

 //UniformDouble();
 Int();
 
 return EXIT_SUCCESS;

}

void UniformDouble() {

 typedef itk::Statistics::MersenneTwisterRandomVariateGenerator GeneratorType;
 GeneratorType::Pointer generator = GeneratorType::New();
 generator->Initialize();
 std::cout << generator->GetUniformVariate(0, 5) << std::endl;

}

void Int() {

 typedef itk::Statistics::MersenneTwisterRandomVariateGenerator GeneratorType;
 GeneratorType::Pointer generator = GeneratorType::New();
 generator->Initialize();
 std::cout << generator->GetIntegerVariate(5) << std::endl; // Get an int between 0 and 5 (inclusive - that is sample from the set {0,1,2,3,4,5})

} </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(MersenneTwisterRandomVariateGenerator)

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(MersenneTwisterRandomVariateGenerator MersenneTwisterRandomVariateGenerator.cxx) TARGET_LINK_LIBRARIES(MersenneTwisterRandomVariateGenerator ITKCommon ITKStatistics)


</source>