Skip to content

chloe0x0/Mersenne-Twister

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mersenne-Twister

A C implementation of the MT19937 and MT19937-64. Both implementations intend to match the original paper's C implementation

Usage

MT19937.c

#include <stdio.h>
#include <time.h>
#include "MT19937.h"

int main(void){
    MT19937 mt;
    // Seed Mersenne Twister
    SeedMT(time(NULL), &mt);

    // Generate 10 Natural Numbers
    for (int i = 0; i < 10; ++i){
        printf("%lf ", MT_GenNat(&mt));
    }
    printf("\n");

    // Generate 10 Real Numbers in the range [0, 1]
    for (int i = 0; i < 10; ++i){
        printf("%lf ", MT_GenReal(&mt));
    }
}

250x250 Random Noise Generated by the MT19937 implementation

The Original Paper

Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator

C program on page 22

Original MT19937-64 C Code

A C-program for MT19937-64

Additional Resources

Wikipedia

About

A C implementation of the Mersenne Twister

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages