├── .gitignore ├── LICENSE ├── README.md ├── README.raw.md ├── SampleZoo.jpg ├── building.md ├── codegen.lua ├── contributesampletest.md ├── contributing.md ├── credits.md ├── datacache ├── cache.dat └── cache.txt ├── doc ├── bestcandidate.md ├── bluenoise.md ├── dft.md ├── progressive.md └── randomized.md ├── docgen.lua ├── fonts ├── Apache License.txt └── OpenSans-Regular.ttf ├── output ├── _1d │ ├── samples │ │ ├── blue_noise │ │ │ ├── CalculateDiscrepancy.png │ │ │ ├── DFT_BestCandidate.png │ │ │ ├── DFT_BestCandidate10.png │ │ │ ├── DFT_BestCandidate5.png │ │ │ ├── Doc_CalculateDiscrepancy.png │ │ │ ├── Doc_Quadratic.png │ │ │ ├── Exp.png │ │ │ ├── Linear.png │ │ │ ├── MakeNumberline_BestCandidate.png │ │ │ ├── MakeNumberline_BestCandidate10.png │ │ │ ├── MakeNumberline_BestCandidate5.png │ │ │ ├── Quadratic.png │ │ │ ├── Step.png │ │ │ ├── page.md │ │ │ └── results.md │ │ ├── irrational_numbers │ │ │ ├── CalculateDiscrepancy.png │ │ │ ├── DFT_GoldenRatio.png │ │ │ ├── DFT_GoldenRatioZero.png │ │ │ ├── DFT_Pi.png │ │ │ ├── DFT_Sqrt2.png │ │ │ ├── Exp.png │ │ │ ├── Linear.png │ │ │ ├── MakeNumberline_GoldenRatio.png │ │ │ ├── MakeNumberline_GoldenRatioZero.png │ │ │ ├── MakeNumberline_Pi.png │ │ │ ├── MakeNumberline_Sqrt2.png │ │ │ ├── Quadratic.png │ │ │ ├── Step.png │ │ │ ├── page.md │ │ │ └── results.md │ │ ├── lds │ │ │ ├── CalculateDiscrepancy.png │ │ │ ├── DFT_Sobol.png │ │ │ ├── DFT_VanDerCorput2.png │ │ │ ├── DFT_VanDerCorput3.png │ │ │ ├── DFT_VanDerCorput5.png │ │ │ ├── Exp.png │ │ │ ├── Linear.png │ │ │ ├── MakeNumberline_Sobol.png │ │ │ ├── MakeNumberline_VanDerCorput2.png │ │ │ ├── MakeNumberline_VanDerCorput3.png │ │ │ ├── MakeNumberline_VanDerCorput5.png │ │ │ ├── Quadratic.png │ │ │ ├── Step.png │ │ │ ├── page.md │ │ │ └── results.md │ │ ├── regular │ │ │ ├── CalculateDiscrepancy.png │ │ │ ├── DFT_Regular.png │ │ │ ├── DFT_RegularCentered.png │ │ │ ├── DFT_RegularCenteredOffset.png │ │ │ ├── DFT_RegularJittered.png │ │ │ ├── Exp.png │ │ │ ├── Linear.png │ │ │ ├── MakeNumberline_Regular.png │ │ │ ├── MakeNumberline_RegularCentered.png │ │ │ ├── MakeNumberline_RegularCenteredOffset.png │ │ │ ├── MakeNumberline_RegularJittered.png │ │ │ ├── Quadratic.png │ │ │ ├── Step.png │ │ │ ├── page.md │ │ │ └── results.md │ │ └── uniform_random │ │ │ ├── CalculateDiscrepancy.png │ │ │ ├── DFT_UniformRandom.png │ │ │ ├── Exp.png │ │ │ ├── Linear.png │ │ │ ├── MakeNumberline_UniformRandom.png │ │ │ ├── Quadratic.png │ │ │ ├── Step.png │ │ │ ├── page.md │ │ │ └── results.md │ └── tests │ │ ├── dft │ │ ├── page.md │ │ └── results.md │ │ ├── discrepancy │ │ ├── page.md │ │ └── results.md │ │ ├── integration │ │ ├── exp.png │ │ ├── linear.png │ │ ├── page.md │ │ ├── quadratic.png │ │ ├── results.md │ │ └── step.png │ │ └── numberline │ │ ├── page.md │ │ └── results.md └── _2d │ ├── samples │ ├── blue_noise │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_BestCandidate.png │ │ ├── DFT_BestCandidate10.png │ │ ├── DFT_BestCandidate5.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_BestCandidate.png │ │ ├── MakePlot_BestCandidate10.png │ │ ├── MakePlot_BestCandidate5.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ ├── irrational_numbers │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_R2.png │ │ ├── DFT_R2Jittered.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_R2.png │ │ ├── MakePlot_R2Jittered.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ ├── lds │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_Halton_13_9.png │ │ ├── DFT_Halton_2_3.png │ │ ├── DFT_Halton_2_3_Zero.png │ │ ├── DFT_Halton_5_7.png │ │ ├── DFT_NRooks.png │ │ ├── DFT_Sobol.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_Halton_13_9.png │ │ ├── MakePlot_Halton_2_3.png │ │ ├── MakePlot_Halton_2_3_Zero.png │ │ ├── MakePlot_Halton_5_7.png │ │ ├── MakePlot_NRooks.png │ │ ├── MakePlot_Sobol.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ ├── lds_hammersley │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_Hammersley2.png │ │ ├── DFT_Hammersley2NoOffset.png │ │ ├── DFT_Hammersley2_1Bit.png │ │ ├── DFT_Hammersley2_2Bit.png │ │ ├── DFT_Hammersley2_3Bit.png │ │ ├── DFT_Hammersley2_4Bit.png │ │ ├── DFT_Hammersley3.png │ │ ├── DFT_Hammersley5.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_Hammersley2.png │ │ ├── MakePlot_Hammersley2NoOffset.png │ │ ├── MakePlot_Hammersley2_1Bit.png │ │ ├── MakePlot_Hammersley2_2Bit.png │ │ ├── MakePlot_Hammersley2_3Bit.png │ │ ├── MakePlot_Hammersley2_4Bit.png │ │ ├── MakePlot_Hammersley3.png │ │ ├── MakePlot_Hammersley5.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ ├── regular │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_Regular.png │ │ ├── DFT_RegularCentered.png │ │ ├── DFT_RegularCenteredOffset.png │ │ ├── DFT_RegularJittered.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_Regular.png │ │ ├── MakePlot_RegularCentered.png │ │ ├── MakePlot_RegularCenteredOffset.png │ │ ├── MakePlot_RegularJittered.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ └── uniform_random │ │ ├── Bilinear.png │ │ ├── CalculateDiscrepancy.png │ │ ├── DFT_UniformRandom.png │ │ ├── Disk.png │ │ ├── Gaussian.png │ │ ├── MakePlot_UniformRandom.png │ │ ├── Step.png │ │ ├── Triangle.png │ │ ├── page.md │ │ └── results.md │ └── tests │ ├── dft │ ├── page.md │ └── results.md │ ├── discrepancy │ ├── page.md │ └── results.md │ ├── integration │ ├── bilinear.png │ ├── disk.png │ ├── gaussian.png │ ├── page.md │ ├── results.md │ ├── step.png │ └── triangle.png │ └── plot │ ├── page.md │ └── results.md ├── premake5.exe ├── premake5.lua ├── src ├── families │ ├── _1d │ │ ├── samples │ │ │ ├── blue_noise │ │ │ │ ├── blue_noise.cpp │ │ │ │ ├── manual_test.h │ │ │ │ ├── samples.lua │ │ │ │ └── samples.md │ │ │ ├── irrational_numbers │ │ │ │ ├── irrational_numbers.cpp │ │ │ │ ├── samples.lua │ │ │ │ └── samples.md │ │ │ ├── lds │ │ │ │ ├── LDS.cpp │ │ │ │ ├── samples.lua │ │ │ │ └── samples.md │ │ │ ├── regular │ │ │ │ ├── regular.cpp │ │ │ │ ├── samples.lua │ │ │ │ └── samples.md │ │ │ └── uniform_random │ │ │ │ ├── samples.lua │ │ │ │ ├── samples.md │ │ │ │ └── uniform_random.cpp │ │ └── tests │ │ │ ├── dft │ │ │ ├── dft.cpp │ │ │ ├── tests.lua │ │ │ └── tests.md │ │ │ ├── discrepancy │ │ │ ├── discrepancy.cpp │ │ │ ├── tests.lua │ │ │ └── tests.md │ │ │ ├── integration │ │ │ ├── integration.cpp │ │ │ ├── manual_test.h │ │ │ ├── tests.lua │ │ │ └── tests.md │ │ │ └── numberline │ │ │ ├── numberline.cpp │ │ │ ├── tests.lua │ │ │ └── tests.md │ └── _2d │ │ ├── samples │ │ ├── blue_noise │ │ │ ├── blue_noise.cpp │ │ │ ├── samples.lua │ │ │ └── samples.md │ │ ├── irrational_numbers │ │ │ ├── irrational_numbers.cpp │ │ │ ├── samples.lua │ │ │ └── samples.md │ │ ├── lds │ │ │ ├── LDS.cpp │ │ │ ├── samples.lua │ │ │ └── samples.md │ │ ├── lds_hammersley │ │ │ ├── LDSHammersley.cpp │ │ │ ├── samples.lua │ │ │ └── samples.md │ │ ├── regular │ │ │ ├── regular.cpp │ │ │ ├── samples.lua │ │ │ └── samples.md │ │ └── uniform_random │ │ │ ├── samples.lua │ │ │ ├── samples.md │ │ │ └── uniform_random.cpp │ │ └── tests │ │ ├── dft │ │ ├── dft.cpp │ │ ├── tests.lua │ │ └── tests.md │ │ ├── discrepancy │ │ ├── discrepancy.cpp │ │ ├── tests.lua │ │ └── tests.md │ │ ├── integration │ │ ├── integration.cpp │ │ ├── manual_test.h │ │ ├── tests.lua │ │ └── tests.md │ │ └── plot │ │ ├── plot.cpp │ │ ├── tests.lua │ │ └── tests.md ├── main.cpp ├── shared │ ├── color_spaces.h │ ├── datacache.cpp │ ├── datacache.h │ ├── drawing.cpp │ ├── drawing.h │ ├── drawtext.cpp │ ├── drawtext.h │ ├── fnv1a.h │ ├── graph.cpp │ ├── graph.h │ ├── image.cpp │ ├── image.h │ ├── math.h │ ├── pixel.h │ └── vector.h ├── simple_fft │ ├── check_fft.hpp │ ├── copy_array.hpp │ ├── error_handling.hpp │ ├── fft.h │ ├── fft.hpp │ ├── fft_impl.hpp │ └── fft_settings.h └── stb │ ├── README.md │ ├── stb_image.h │ ├── stb_image_write.h │ └── stb_truetype.h └── toc.md /.gitignore: -------------------------------------------------------------------------------- 1 | build/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alan Wolfe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.raw.md: -------------------------------------------------------------------------------- 1 | ![SampleZoo](SampleZoo.jpg) 2 | 3 | # Table of Contents 4 | 5 | * [Progressive and Open Sequences](./doc/progressive.md) 6 | * [Randomized vs Deterministic Sequences](./doc/randomized.md) 7 | * [Discrete Fourier Transform (DFT) Testing](./doc/dft.md) 8 | 9 | ## Blue Noise Algorithms 10 | 11 | * [What is blue noise?](./doc/bluenoise.md) 12 | * [Mitchell's Best Candidate Algorithm](./doc/bestcandidate.md) 13 | 14 | TOCTOC 15 | 16 | # SampleZoo 17 | Simple copy/paste-able implementations of sampling patterns, with objective and subjective tests to compare them, along with understandable explanations. 18 | 19 | Created by Alan Wolfe 20 | email: alan.wolfe@gmail.com 21 | twitter: https://twitter.com/Atrix256 22 | 23 | Building and running this code: [building](building.md) 24 | 25 | Everything in this repository is under the [MIT License](LICENSE) unless otherwise stated in the source file. 26 | 27 | Full list of contributors here: [credits](credits.md) 28 | 29 | Information on how to contribute to this project: [contributing](contributing.md) 30 | 31 | # Why Does This Exist?? 32 | 33 | My interest in sampling patterns is mainly for use in numerical integration techniques in real time graphics. In that situation, you usually want a sequence that will converge with as few samples as possible, and give a pleasing error pattern when it hasn't fully converged. 34 | 35 | This stuff is surprisingly nuanced, and new sampling techniques come out every year as researchers continue to push the envelope. 36 | 37 | It can be hard to find implementations for some sampling patterns, especially if they are newly published. Furthermore, each sampling paper seems to use different testing methods to show properties of their sequences, which can make it hard to compare against other sample sequences. 38 | 39 | My goal is to get as many implemented and tested as possible, including new ones as they come out, so this stuff is more accessible and usable by the folks who could benefit from it. 40 | 41 | It's a lot of work for one person though, so Sample Zoo need your help! 42 | 43 | # Other Software Used 44 | 45 | * **STB** - https://github.com/nothings/stb. This is used to read and write images, and render true type text. Very cool set of header only libraries from Sean Barrett https://twitter.com/nothings. 46 | * **Premake5** - a nice way to generate project and solution files from code. Because premake scripts are lua, I also have the premake script call into the lua files that generate code and documentation - such as the table of contents page! https://premake.github.io/ 47 | * **simple_fft** - https://github.com/d1vanov/Simple-FFT. A header only library implementing the fast discrete fourier transform. Used for frequency analysis. 48 | -------------------------------------------------------------------------------- /SampleZoo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/SampleZoo.jpg -------------------------------------------------------------------------------- /building.md: -------------------------------------------------------------------------------- 1 | # Building 2 | 3 | This project uses premake5 and includes a windows binary for that downloaded from https://premake.github.io/. 4 | 5 | To create the solution in windows, open a command prompt in the main folder and run: ./premake5.exe vs2017 6 | 7 | The project and solution files will be inside the build folder, as well as any intermediary files from compiling, and the final executables. 8 | 9 | Note that this creates a solution for visual studio 2017, but other targets are supported. See this page for more information: https://github.com/premake/premake-core/wiki/Using-Premake 10 | 11 | Once the solution is created, open it up and compile / run as normal. 12 | -------------------------------------------------------------------------------- /credits.md: -------------------------------------------------------------------------------- 1 | # Credits 2 | 3 | SampleZoo was created by Alan Wolfe (alan.wolfe@gmail.com) 4 | 5 | If you are interested in getting your name here on the credits, check out this page for information on how to contribute: [contributing](contributing.md) 6 | 7 | Anyone who submits anything to this repository - whether it's a small change or a large number of new features - is entitled to be listed as a contributor. Feel free to include adding your name here in any pull requests you make. 8 | 9 | ## Code Contributors 10 | 11 | These are people who have contributed code to this project: 12 | 13 | 14 | ## Other Contributors 15 | 16 | These are people who have corrected terminology, added sampling strategies to the TODO list, or have made other important non-code contributions: 17 | 18 | ## The Twitter Graphics Community 19 | 20 | Twitter has an AMAZING graphics community full of professionals, indie developers, artists, researchers and more. I would list all the folks who have helped me learn these things over the years but I would leave important people out and feelings would get hurt. Go see the people I follow and follow them too: https://twitter.com/Atrix256 21 | -------------------------------------------------------------------------------- /datacache/cache.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/datacache/cache.dat -------------------------------------------------------------------------------- /datacache/cache.txt: -------------------------------------------------------------------------------- 1 | ---------- Samples 1D ---------- 2 | 3 | 3 keys 4 | blue_noise::BestCandidate - 10001 entries, 5136384 bytes 5 | blue_noise::BestCandidate10 - 10001 entries, 5136384 bytes 6 | blue_noise::BestCandidate5 - 10001 entries, 5136384 bytes 7 | 8 | ---------- RNG Seeds ---------- 9 | 10 | 8 keys 11 | blue_noise::BestCandidate - 32 bytes 12 | blue_noise::BestCandidate10 - 32 bytes 13 | blue_noise::BestCandidate5 - 32 bytes 14 | blue_noise::BestCandidateRefined - 32 bytes 15 | irrational_numbers::R2Jittered - 32 bytes 16 | lds::NRooks - 32 bytes 17 | regular::RegularJittered - 32 bytes 18 | uniform_random::UniformRandom - 32 bytes 19 | 20 | ---------- Samples 2D ---------- 21 | 22 | 3 keys 23 | blue_noise::BestCandidate - 2 entries, 40976 bytes 24 | blue_noise::BestCandidate10 - 2 entries, 40976 bytes 25 | blue_noise::BestCandidate5 - 2 entries, 40976 bytes 26 | 27 | -------------------------------------------------------------------------------- /doc/bestcandidate.md: -------------------------------------------------------------------------------- 1 | # Mitchell's Best Candidate Algorithm 2 | 3 | This algorithm iteratively generates a number of random candidates (white noise) and chooses the candidate which has the best blue noise properties (largest distance from it's nearest neighbor). 4 | 5 | The paper that describes the algorithm originally (in papers section below) says that that the number of candidates should scale up with the number of points you already have to keep consistent frequency content at different sample counts. I've found that keeping the multiplier at 1.0 seems to be best. 6 | 7 | This algorithm generates a progressive sequence which means that if you generate N sample points, any subset of those sample points starting at 0 is also blue noise. Also, you can add more sample points to an existing set of sample points, without having to throw out all the points you already made. 8 | 9 | This property can be very useful for when you don't know how many samples you want to take in advance, or if you are using it for rendering, being able to preview the image as it renders and see something more representative of the final image. With a non progressive sequence used in rendering, the image looks very bad until the end. 10 | 11 | ## Links 12 | 13 | https://blog.demofox.org/2017/10/20/generating-blue-noise-sample-points-with-mitchells-best-candidate-algorithm/ - Generating Blue Noise Sample Points With Mitchell’s Best Candidate Algorithm 14 | 15 | ## Papers 16 | 17 | http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.556.445&rep=rep1&type=pdf - "Spectrally Optimal Sampling for Distribution Ray Tracing" by Don P. Mitchell 1991 -------------------------------------------------------------------------------- /doc/dft.md: -------------------------------------------------------------------------------- 1 | # Discrete Fourier Transform (DFT) Testing 2 | 3 | The discrete Fourier transform transforms a sampling sequence into frequency space. How this is done in each sample family varies, but the DFT test documentation for that sample family should explain the details. 4 | 5 | Viewing the samples in frequency space can help you understand some properties of the sampling sequence. 6 | 7 | For instance, blue noise is missing low frequency content, so you could see how jittered grid looks compared to blue noise in frequency space. They both are missing low frequency components, but look very different in frequency space despite this. 8 | 9 | Below is the DFT of 1d blue noise made with the best candidate algorithm, and 1d jittered grid. 10 | 11 | ![BestCandidate](../output/_1d/samples/blue_noise/DFT_BestCandidate.png) 12 | 13 | ![RegularJittered](../output/_1d/samples/regular/DFT_RegularJittered.png) -------------------------------------------------------------------------------- /doc/progressive.md: -------------------------------------------------------------------------------- 1 | # Progressive and Open Sequences 2 | 3 | ## Progressive Sequences 4 | 5 | Progressive sequences are sequences that keep their desirable properties when using a subset of the entire sequence. 6 | 7 | For instance, random numbers are a progressive sequence. If you have 5 random numbers but only want 3, you can just throw away the last 2 and you still have 3 perfectly good random numbers. 8 | 9 | For most progressive sequences, it's the end that you need to remove samples from to keep the sequence valid, but some sequences have less restrictive rules. Random numbers are trivially progressive for any subset. Sobol is progressive for any power of two region. 10 | 11 | Non progressive sequences are sequences where if you want to change the sample count in the sequence, you have to recreate them from scratch. 12 | 13 | An example of a non progressive sequence is regular sampling. 14 | 15 | Let's say you had 4 regular sampled points in [0,1) : 0, 0.25, 0.5, 0.75 16 | 17 | If you only wanted to use 3 of those samples, it wouldn't be regularly sampled points anymore. It would be 0, 0.25, 0.5 instead of 0, 0.333, 0.666. 18 | 19 | ## Open Sequences 20 | 21 | Open sequences are sequences that are unbounded in size. 22 | 23 | Random numbers are an open sequence: you can add more random numbers to the end, and the sequence as a whole is still perfectly random. 24 | 25 | Regularly sampled points are not open though. If you have 4 points: 0, 0.25, 0.5, 0.75, you can't just add a 5th point, you have to remake the sequence from scratch for 5 samples to get 0, 0.2, 0.4, 0.6, 0.8. 26 | 27 | Van Der Corput is an example of a non trivial open sequence. You can keep adding more and more Van Der Corput points to infinity. 28 | 29 | All open sequences are progressive, but not all progressive sequences are open. 30 | 31 | As a more complex example, you could use CCVD to make 512 blue noise sample points, and use techniques from the void and cluster algorithm to make those sample points progressive, but you can't add any more new points after the fact without re-running the relaxation algorithm and invalidating all the existing points. 32 | 33 | ## Sets vs Sequences 34 | 35 | Sometimes people will refer to samples as sets or sequences. 36 | 37 | Sequences have an ordering while sets do not. 38 | 39 | ## Sample Zoo Context 40 | 41 | Some tests behave differently for progressive or non progressive sampling sequences, but the test documentation should explain the differences. 42 | 43 | An example of where this comes up is in numerical integration, where you are graphing the sample count on the x axis and the integration error on the y axis. 44 | 45 | If you are graphing 1 to N samples, for progressive sequences you can just generate an N sample sequence and graph the integration error at each step in the sequence. 46 | 47 | For non progressive sequences, it gets a little more difficult though. You need to generate a sequence for EVERY sample count 1 to N and calculate the sample count of that sequence. 48 | 49 | The reason for this is because a non progressive sequence is almost always going to have A LOT of integration error in the beginning, regardless of how much error it gets to in the end. 50 | 51 | If we don't do that, we aren't giving a fair apples to apples test between the sequences. Nobody is going to use a non progressive sequence and expect it to keep up with a progressive sequence in integration error for intermediate samples. 52 | 53 | Below you can see the numberline for the golden ratio sequence, which is progressive. Note how each sample count contains all previous samples. Below that is a regular sampling sequence which is not progressive. Note how each sample count DOES NOT contain all previous samples 54 | 55 | ![RegularJittered](../output/_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png) 56 | ![RegularJittered](../output/_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png) -------------------------------------------------------------------------------- /doc/randomized.md: -------------------------------------------------------------------------------- 1 | # Randomized vs Deterministic Sequences 2 | 3 | Randomized sequences are sequences that use random numbers as part of generating sample points. 4 | 5 | Deterministic sequences are sequences that don't. 6 | 7 | As a high level concept, comparing regular sampling vs uniform random sampling (white noise), regular sampling has problems with aliasing while uniform random sampling trades the aliasing for noise, which is usually desired. 8 | 9 | Because of this, randomized sequences will usually have less aliasing than their deterministic counterparts. 10 | 11 | This can get murky though because ultimately, the "randomized sequences" are using deterministic, but chaotic, functions to generate the "random numbers". 12 | 13 | Some sampling sequences can also be described as deterministic, but chaotic, which blurs the line between randomized and deterministic sequences. 14 | 15 | To bring it back from philisophical debates about the nature of randomness, we can use these definitions: 16 | * Randomized sequences will come up with different results each time a new sequence with the same number of points is generated. 17 | * Deterministic sequences will always come up with the same results each time a new sequence with the same number of points is generated. 18 | 19 | ## Sample Zoo Context 20 | 21 | Some tests behave differently for randomized vs deterministic sampling sequences, but the test documentation should explain the differences. 22 | 23 | For instance, the 1d DFT test works differently for randomized and deterministic sequences. 24 | 25 | For deterministic sequences, it makes a single sequence, DFTs it and shows the results. 26 | 27 | For randomized sequences, it generates several sequences, DFTs them, and reports the maximum, the minimum, and the average. 28 | 29 | It does this because any single instantiation of a randomized sequence isn't going to tell you much about what to expect from that sequence. By gathering statistics of the sequence over several runs, you get a better idea of the sort of things to expect from the sequence. 30 | 31 | Below you can see the DFT for 1d blue noise, which is randomized, and sobol which is not randomized (it is deterministic). 32 | 33 | ![RegularJittered](../output/_1d/samples/regular/DFT_RegularJittered.png) 34 | ![RegularJittered](../output/_1d/samples/lds/DFT_Sobol.png) 35 | 36 | -------------------------------------------------------------------------------- /fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/DFT_BestCandidate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/DFT_BestCandidate.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/DFT_BestCandidate10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/DFT_BestCandidate10.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/DFT_BestCandidate5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/DFT_BestCandidate5.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Doc_CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Doc_CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Doc_Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Doc_Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Exp.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Linear.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/MakeNumberline_BestCandidate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/MakeNumberline_BestCandidate.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/blue_noise/Step.png -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/page.md: -------------------------------------------------------------------------------- 1 | # Blue Noise Sequences 2 | Source Code: [src/families/_1d/samples/blue_noise/](../../../../src/families/_1d/samples/blue_noise/) 3 | 4 | Blue noise samples are randomized but roughly evenly spaced. 5 | 6 | More details: [What is Blue Noise?](../../../../doc/bluenoise.md) 7 | 8 | There are many ways to generate 1d blue noise sample points, but there currently is only one way implemented: 9 | * [Mitchell's Best Candidate](../../../../doc/bestcandidate.md) 10 | 11 | There are three variations, each using a different multiplier for the number of candidates generated compared to how many blue noise samples there already are: 1, 5 and 10. 12 | 13 | # Comparison vs Other Sequences 14 | 15 | ![BestCandidateRefined](../../../_1d/samples/blue_noise/Doc_CalculateDiscrepancy.png) 16 | ![BestCandidateRefined](../../../_1d/samples/blue_noise/Doc_Quadratic.png) 17 | 18 | # Test Results 19 | samples tested: 20 | * BestCandidate (Progressive, Randomized) 21 | * BestCandidate5 (Progressive, Randomized) 22 | * BestCandidate10 (Progressive, Randomized) 23 | ## BestCandidate 24 | ### Discrete Fourier Transform 25 | ![BestCandidate](../../../_1d/samples/blue_noise/DFT_BestCandidate.png) 26 | ### Numberline 27 | ![BestCandidate](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate.png) 28 | ## BestCandidate5 29 | ### Discrete Fourier Transform 30 | ![BestCandidate5](../../../_1d/samples/blue_noise/DFT_BestCandidate5.png) 31 | ### Numberline 32 | ![BestCandidate5](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png) 33 | ## BestCandidate10 34 | ### Discrete Fourier Transform 35 | ![BestCandidate10](../../../_1d/samples/blue_noise/DFT_BestCandidate10.png) 36 | ### Numberline 37 | ![BestCandidate10](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png) 38 | ## Discrepancy Test 39 | ![blue_noise](../../../_1d/samples/blue_noise/CalculateDiscrepancy.png) 40 | ## Numerical Integration 41 | ### Linear 42 | ![blue_noise](../../../_1d/samples/blue_noise/Linear.png) 43 | ### Step 44 | ![blue_noise](../../../_1d/samples/blue_noise/Step.png) 45 | ### Exp 46 | ![blue_noise](../../../_1d/samples/blue_noise/Exp.png) 47 | ### Quadratic 48 | ![blue_noise](../../../_1d/samples/blue_noise/Quadratic.png) 49 | -------------------------------------------------------------------------------- /output/_1d/samples/blue_noise/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * BestCandidate (Progressive, Randomized) 4 | * BestCandidate5 (Progressive, Randomized) 5 | * BestCandidate10 (Progressive, Randomized) 6 | ## BestCandidate 7 | ### Discrete Fourier Transform 8 | ![BestCandidate](../../../_1d/samples/blue_noise/DFT_BestCandidate.png) 9 | ### Numberline 10 | ![BestCandidate](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate.png) 11 | ## BestCandidate5 12 | ### Discrete Fourier Transform 13 | ![BestCandidate5](../../../_1d/samples/blue_noise/DFT_BestCandidate5.png) 14 | ### Numberline 15 | ![BestCandidate5](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png) 16 | ## BestCandidate10 17 | ### Discrete Fourier Transform 18 | ![BestCandidate10](../../../_1d/samples/blue_noise/DFT_BestCandidate10.png) 19 | ### Numberline 20 | ![BestCandidate10](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png) 21 | ## Discrepancy Test 22 | ![blue_noise](../../../_1d/samples/blue_noise/CalculateDiscrepancy.png) 23 | ## Numerical Integration 24 | ### Linear 25 | ![blue_noise](../../../_1d/samples/blue_noise/Linear.png) 26 | ### Step 27 | ![blue_noise](../../../_1d/samples/blue_noise/Step.png) 28 | ### Exp 29 | ![blue_noise](../../../_1d/samples/blue_noise/Exp.png) 30 | ### Quadratic 31 | ![blue_noise](../../../_1d/samples/blue_noise/Quadratic.png) 32 | -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/DFT_GoldenRatio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/DFT_GoldenRatio.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/DFT_GoldenRatioZero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/DFT_GoldenRatioZero.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/DFT_Pi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/DFT_Pi.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/DFT_Sqrt2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/DFT_Sqrt2.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/Exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/Exp.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/Linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/Linear.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/MakeNumberline_GoldenRatioZero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/MakeNumberline_GoldenRatioZero.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/MakeNumberline_Pi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/MakeNumberline_Pi.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/MakeNumberline_Sqrt2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/MakeNumberline_Sqrt2.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/irrational_numbers/Step.png -------------------------------------------------------------------------------- /output/_1d/samples/irrational_numbers/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * GoldenRatioZero (Progressive, Deterministic) 4 | * GoldenRatio (Progressive, Deterministic) 5 | * Pi (Progressive, Deterministic) 6 | * Sqrt2 (Progressive, Deterministic) 7 | ## GoldenRatioZero 8 | ### Discrete Fourier Transform 9 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/DFT_GoldenRatioZero.png) 10 | ### Numberline 11 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatioZero.png) 12 | ## GoldenRatio 13 | ### Discrete Fourier Transform 14 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/DFT_GoldenRatio.png) 15 | ### Numberline 16 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png) 17 | ## Pi 18 | ### Discrete Fourier Transform 19 | ![Pi](../../../_1d/samples/irrational_numbers/DFT_Pi.png) 20 | ### Numberline 21 | ![Pi](../../../_1d/samples/irrational_numbers/MakeNumberline_Pi.png) 22 | ## Sqrt2 23 | ### Discrete Fourier Transform 24 | ![Sqrt2](../../../_1d/samples/irrational_numbers/DFT_Sqrt2.png) 25 | ### Numberline 26 | ![Sqrt2](../../../_1d/samples/irrational_numbers/MakeNumberline_Sqrt2.png) 27 | ## Discrepancy Test 28 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/CalculateDiscrepancy.png) 29 | ## Numerical Integration 30 | ### Linear 31 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Linear.png) 32 | ### Step 33 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Step.png) 34 | ### Exp 35 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Exp.png) 36 | ### Quadratic 37 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Quadratic.png) 38 | -------------------------------------------------------------------------------- /output/_1d/samples/lds/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/DFT_Sobol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/DFT_Sobol.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/DFT_VanDerCorput2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/DFT_VanDerCorput2.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/DFT_VanDerCorput3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/DFT_VanDerCorput3.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/DFT_VanDerCorput5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/DFT_VanDerCorput5.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/Exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/Exp.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/Linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/Linear.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/MakeNumberline_Sobol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/MakeNumberline_Sobol.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/MakeNumberline_VanDerCorput2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/MakeNumberline_VanDerCorput2.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/MakeNumberline_VanDerCorput3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/MakeNumberline_VanDerCorput3.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/MakeNumberline_VanDerCorput5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/MakeNumberline_VanDerCorput5.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/lds/Step.png -------------------------------------------------------------------------------- /output/_1d/samples/lds/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * Sobol (Progressive, Deterministic) 4 | * VanDerCorput2 (Progressive, Deterministic) 5 | * VanDerCorput3 (Progressive, Deterministic) 6 | * VanDerCorput5 (Progressive, Deterministic) 7 | ## Sobol 8 | ### Discrete Fourier Transform 9 | ![Sobol](../../../_1d/samples/lds/DFT_Sobol.png) 10 | ### Numberline 11 | ![Sobol](../../../_1d/samples/lds/MakeNumberline_Sobol.png) 12 | ## VanDerCorput2 13 | ### Discrete Fourier Transform 14 | ![VanDerCorput2](../../../_1d/samples/lds/DFT_VanDerCorput2.png) 15 | ### Numberline 16 | ![VanDerCorput2](../../../_1d/samples/lds/MakeNumberline_VanDerCorput2.png) 17 | ## VanDerCorput3 18 | ### Discrete Fourier Transform 19 | ![VanDerCorput3](../../../_1d/samples/lds/DFT_VanDerCorput3.png) 20 | ### Numberline 21 | ![VanDerCorput3](../../../_1d/samples/lds/MakeNumberline_VanDerCorput3.png) 22 | ## VanDerCorput5 23 | ### Discrete Fourier Transform 24 | ![VanDerCorput5](../../../_1d/samples/lds/DFT_VanDerCorput5.png) 25 | ### Numberline 26 | ![VanDerCorput5](../../../_1d/samples/lds/MakeNumberline_VanDerCorput5.png) 27 | ## Discrepancy Test 28 | ![lds](../../../_1d/samples/lds/CalculateDiscrepancy.png) 29 | ## Numerical Integration 30 | ### Linear 31 | ![lds](../../../_1d/samples/lds/Linear.png) 32 | ### Step 33 | ![lds](../../../_1d/samples/lds/Step.png) 34 | ### Exp 35 | ![lds](../../../_1d/samples/lds/Exp.png) 36 | ### Quadratic 37 | ![lds](../../../_1d/samples/lds/Quadratic.png) 38 | -------------------------------------------------------------------------------- /output/_1d/samples/regular/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/DFT_Regular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/DFT_Regular.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/DFT_RegularCentered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/DFT_RegularCentered.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/DFT_RegularCenteredOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/DFT_RegularCenteredOffset.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/DFT_RegularJittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/DFT_RegularJittered.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/Exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/Exp.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/Linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/Linear.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/MakeNumberline_Regular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/MakeNumberline_Regular.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/MakeNumberline_RegularCentered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/MakeNumberline_RegularCentered.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/MakeNumberline_RegularJittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/MakeNumberline_RegularJittered.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/regular/Step.png -------------------------------------------------------------------------------- /output/_1d/samples/regular/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * Regular (Not Progressive, Deterministic) 4 | * RegularCentered (Not Progressive, Deterministic) 5 | * RegularCenteredOffset (Not Progressive, Deterministic) 6 | * RegularJittered (Not Progressive, Randomized) 7 | ## Regular 8 | ### Discrete Fourier Transform 9 | ![Regular](../../../_1d/samples/regular/DFT_Regular.png) 10 | ### Numberline 11 | ![Regular](../../../_1d/samples/regular/MakeNumberline_Regular.png) 12 | ## RegularCentered 13 | ### Discrete Fourier Transform 14 | ![RegularCentered](../../../_1d/samples/regular/DFT_RegularCentered.png) 15 | ### Numberline 16 | ![RegularCentered](../../../_1d/samples/regular/MakeNumberline_RegularCentered.png) 17 | ## RegularCenteredOffset 18 | ### Discrete Fourier Transform 19 | ![RegularCenteredOffset](../../../_1d/samples/regular/DFT_RegularCenteredOffset.png) 20 | ### Numberline 21 | ![RegularCenteredOffset](../../../_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png) 22 | ## RegularJittered 23 | ### Discrete Fourier Transform 24 | ![RegularJittered](../../../_1d/samples/regular/DFT_RegularJittered.png) 25 | ### Numberline 26 | ![RegularJittered](../../../_1d/samples/regular/MakeNumberline_RegularJittered.png) 27 | ## Discrepancy Test 28 | ![regular](../../../_1d/samples/regular/CalculateDiscrepancy.png) 29 | ## Numerical Integration 30 | ### Linear 31 | ![regular](../../../_1d/samples/regular/Linear.png) 32 | ### Step 33 | ![regular](../../../_1d/samples/regular/Step.png) 34 | ### Exp 35 | ![regular](../../../_1d/samples/regular/Exp.png) 36 | ### Quadratic 37 | ![regular](../../../_1d/samples/regular/Quadratic.png) 38 | -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/DFT_UniformRandom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/DFT_UniformRandom.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/Exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/Exp.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/Linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/Linear.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/MakeNumberline_UniformRandom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/MakeNumberline_UniformRandom.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/Quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/Quadratic.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/samples/uniform_random/Step.png -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/page.md: -------------------------------------------------------------------------------- 1 | # Uniform Random Number Sampling 2 | Source Code: [src/families/_1d/samples/uniform_random/](../../../../src/families/_1d/samples/uniform_random/) 3 | 4 | Uniform random sampling uses random numbers to make sample positions. 5 | 6 | It's called uniform because it uses a uniform distribution of random numbers. 7 | 8 | This is also known as "white noise" because if you look at the DFT, it has equal probability of having amplitudes in all frequencies. 9 | 10 | This is in contrast to blue noise which only has high frequency content or red noise which only has low frequency content. 11 | 12 | Uniform random sampling doesn't have the aliasing problems that regular sampling does, but instead introduces noise, which is an acceptable trade off. 13 | 14 | A problem with white noise is that the point locations are completely random without regard to any of the other point locations, which means that white noise samples can clump together and leave holes. 15 | 16 | The end result is that uniform random sampling is not very quick at numerical integration, and before it converges it can have a very noticeable and jarring noise pattern. 17 | 18 | Here are some uniform random samples: 19 | 20 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 21 | 22 | Blue noise is an alternative to uniform random sampling which has many of the positive characteristics of white noise, but has a better error rate at lower sample counts, and the noise pattern it leaves is more pleasing to the eye due to being more uniformly distributed. 23 | 24 | ## Links 25 | 26 | http://luc.devroye.org/rnbookindex.html "Non-Uniform Random Variate Generation" - a huge book free online, on all things white noise. 27 | 28 | # Test Results 29 | samples tested: 30 | * UniformRandom (Progressive, Randomized) 31 | ## UniformRandom 32 | ### Discrete Fourier Transform 33 | ![UniformRandom](../../../_1d/samples/uniform_random/DFT_UniformRandom.png) 34 | ### Numberline 35 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 36 | ## Discrepancy Test 37 | ![uniform_random](../../../_1d/samples/uniform_random/CalculateDiscrepancy.png) 38 | ## Numerical Integration 39 | ### Linear 40 | ![uniform_random](../../../_1d/samples/uniform_random/Linear.png) 41 | ### Step 42 | ![uniform_random](../../../_1d/samples/uniform_random/Step.png) 43 | ### Exp 44 | ![uniform_random](../../../_1d/samples/uniform_random/Exp.png) 45 | ### Quadratic 46 | ![uniform_random](../../../_1d/samples/uniform_random/Quadratic.png) 47 | -------------------------------------------------------------------------------- /output/_1d/samples/uniform_random/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * UniformRandom (Progressive, Randomized) 4 | ## UniformRandom 5 | ### Discrete Fourier Transform 6 | ![UniformRandom](../../../_1d/samples/uniform_random/DFT_UniformRandom.png) 7 | ### Numberline 8 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 9 | ## Discrepancy Test 10 | ![uniform_random](../../../_1d/samples/uniform_random/CalculateDiscrepancy.png) 11 | ## Numerical Integration 12 | ### Linear 13 | ![uniform_random](../../../_1d/samples/uniform_random/Linear.png) 14 | ### Step 15 | ![uniform_random](../../../_1d/samples/uniform_random/Step.png) 16 | ### Exp 17 | ![uniform_random](../../../_1d/samples/uniform_random/Exp.png) 18 | ### Quadratic 19 | ![uniform_random](../../../_1d/samples/uniform_random/Quadratic.png) 20 | -------------------------------------------------------------------------------- /output/_1d/tests/dft/page.md: -------------------------------------------------------------------------------- 1 | # Discrete Fourier Transform 2 | Source Code: [/src/families/_1d/tests/dft/](../../../../src/families/_1d/tests/dft/) 3 | 4 | The discrete Fourier transform transforms a sampling sequence into frequency space. 5 | 6 | The test generates 128 samples and places them as black dots in a 1024x1 white image, and does a DFT of that image. 7 | 8 | For randomized sampling types, it does this test several times and reports the minimum, the maximum, and the average. Deterministic sampling sequences just do a single run. 9 | 10 | There is no difference in this test for progressive vs non progressive sequences since it only ever generates a single 128 length sequence per sequence type. 11 | 12 | No windowing function is used, but in some cases (non torroidal sampling!), a windowing function may make sense. 13 | 14 | # Test Results 15 | tests done: 16 | * DFT 17 | ## DFT 18 | ### Blue Noise Sequences 19 | #### BestCandidate (Progressive, Randomized) 20 | ![BestCandidate](../../../_1d/samples/blue_noise/DFT_BestCandidate.png) 21 | #### BestCandidate5 (Progressive, Randomized) 22 | ![BestCandidate5](../../../_1d/samples/blue_noise/DFT_BestCandidate5.png) 23 | #### BestCandidate10 (Progressive, Randomized) 24 | ![BestCandidate10](../../../_1d/samples/blue_noise/DFT_BestCandidate10.png) 25 | ### Irrational Number Sampling 26 | #### GoldenRatioZero (Progressive, Deterministic) 27 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/DFT_GoldenRatioZero.png) 28 | #### GoldenRatio (Progressive, Deterministic) 29 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/DFT_GoldenRatio.png) 30 | #### Pi (Progressive, Deterministic) 31 | ![Pi](../../../_1d/samples/irrational_numbers/DFT_Pi.png) 32 | #### Sqrt2 (Progressive, Deterministic) 33 | ![Sqrt2](../../../_1d/samples/irrational_numbers/DFT_Sqrt2.png) 34 | ### Low Discrepancy Sequences 35 | #### Sobol (Progressive, Deterministic) 36 | ![Sobol](../../../_1d/samples/lds/DFT_Sobol.png) 37 | #### VanDerCorput2 (Progressive, Deterministic) 38 | ![VanDerCorput2](../../../_1d/samples/lds/DFT_VanDerCorput2.png) 39 | #### VanDerCorput3 (Progressive, Deterministic) 40 | ![VanDerCorput3](../../../_1d/samples/lds/DFT_VanDerCorput3.png) 41 | #### VanDerCorput5 (Progressive, Deterministic) 42 | ![VanDerCorput5](../../../_1d/samples/lds/DFT_VanDerCorput5.png) 43 | ### Regular Sampling 44 | #### Regular (Not Progressive, Deterministic) 45 | ![Regular](../../../_1d/samples/regular/DFT_Regular.png) 46 | #### RegularCentered (Not Progressive, Deterministic) 47 | ![RegularCentered](../../../_1d/samples/regular/DFT_RegularCentered.png) 48 | #### RegularCenteredOffset (Not Progressive, Deterministic) 49 | ![RegularCenteredOffset](../../../_1d/samples/regular/DFT_RegularCenteredOffset.png) 50 | #### RegularJittered (Not Progressive, Randomized) 51 | ![RegularJittered](../../../_1d/samples/regular/DFT_RegularJittered.png) 52 | ### Uniform Random Number Sampling 53 | #### UniformRandom (Progressive, Randomized) 54 | ![UniformRandom](../../../_1d/samples/uniform_random/DFT_UniformRandom.png) 55 | -------------------------------------------------------------------------------- /output/_1d/tests/dft/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * DFT 4 | ## DFT 5 | ### Blue Noise Sequences 6 | #### BestCandidate (Progressive, Randomized) 7 | ![BestCandidate](../../../_1d/samples/blue_noise/DFT_BestCandidate.png) 8 | #### BestCandidate5 (Progressive, Randomized) 9 | ![BestCandidate5](../../../_1d/samples/blue_noise/DFT_BestCandidate5.png) 10 | #### BestCandidate10 (Progressive, Randomized) 11 | ![BestCandidate10](../../../_1d/samples/blue_noise/DFT_BestCandidate10.png) 12 | ### Irrational Number Sampling 13 | #### GoldenRatioZero (Progressive, Deterministic) 14 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/DFT_GoldenRatioZero.png) 15 | #### GoldenRatio (Progressive, Deterministic) 16 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/DFT_GoldenRatio.png) 17 | #### Pi (Progressive, Deterministic) 18 | ![Pi](../../../_1d/samples/irrational_numbers/DFT_Pi.png) 19 | #### Sqrt2 (Progressive, Deterministic) 20 | ![Sqrt2](../../../_1d/samples/irrational_numbers/DFT_Sqrt2.png) 21 | ### Low Discrepancy Sequences 22 | #### Sobol (Progressive, Deterministic) 23 | ![Sobol](../../../_1d/samples/lds/DFT_Sobol.png) 24 | #### VanDerCorput2 (Progressive, Deterministic) 25 | ![VanDerCorput2](../../../_1d/samples/lds/DFT_VanDerCorput2.png) 26 | #### VanDerCorput3 (Progressive, Deterministic) 27 | ![VanDerCorput3](../../../_1d/samples/lds/DFT_VanDerCorput3.png) 28 | #### VanDerCorput5 (Progressive, Deterministic) 29 | ![VanDerCorput5](../../../_1d/samples/lds/DFT_VanDerCorput5.png) 30 | ### Regular Sampling 31 | #### Regular (Not Progressive, Deterministic) 32 | ![Regular](../../../_1d/samples/regular/DFT_Regular.png) 33 | #### RegularCentered (Not Progressive, Deterministic) 34 | ![RegularCentered](../../../_1d/samples/regular/DFT_RegularCentered.png) 35 | #### RegularCenteredOffset (Not Progressive, Deterministic) 36 | ![RegularCenteredOffset](../../../_1d/samples/regular/DFT_RegularCenteredOffset.png) 37 | #### RegularJittered (Not Progressive, Randomized) 38 | ![RegularJittered](../../../_1d/samples/regular/DFT_RegularJittered.png) 39 | ### Uniform Random Number Sampling 40 | #### UniformRandom (Progressive, Randomized) 41 | ![UniformRandom](../../../_1d/samples/uniform_random/DFT_UniformRandom.png) 42 | -------------------------------------------------------------------------------- /output/_1d/tests/discrepancy/page.md: -------------------------------------------------------------------------------- 1 | # Discrepancy Test 2 | Source Code: [/src/families/_1d/tests/discrepancy/](../../../../src/families/_1d/tests/discrepancy/) 3 | 4 | Discrepancy is a real number given to a sampling sequence that describes how the points clump together or leave holes. 5 | 6 | Discrepancy is calculated by finding the region with the largest difference between actual density of points and expected density if the points were evenly spaced. The region with the largest difference may be either too dense, or too sparse. That difference between actual and expected density in that region is the discrepancy. 7 | 8 | In higher dimensions, the same process is followed with rectangular regions. Sometimes this process will be simplified to just considering regions where one point is at the origin, which is an approximation of discrepancy calculated more quickly, called "Star Discrepancy", which is written as D*. 9 | 10 | CalculateDiscrepancy() calculates discrepancy assuming that 0 and 1 do not wrap around and are "hard walls". 11 | 12 | The right most empty section that it checks for discrepancy is between the right most point and 1.0. 13 | 14 | For a while, I had a torroidal (wrap around) discrepancy calculation test, to analyze sequences for times when you are sampling something that wraps around, like angles on a circle. It ended up being fairly rare that the "wrap around region" was the region with the largest discrepancy so i removed the test, since the graph looked virtually identical to the non wrap around version. 15 | 16 | ## Links 17 | 18 | How to calculate discrepancy: https://math.stackexchange.com/questions/1681562/how-to-calculate-discrepancy-of-a-sequence 19 | 20 | Wikipedia links: 21 | * https://en.wikipedia.org/wiki/Equidistributed_sequence#Discrepancy 22 | * https://en.wikipedia.org/wiki/Low-discrepancy_sequence#Definition_of_discrepancy 23 | 24 | Star Discrepancy from Wolfram Math World: http://mathworld.wolfram.com/StarDiscrepancy.html 25 | 26 | ## Papers 27 | 28 | "Discrepancy as a Quality Measure for Sample Distributions" by Peter Shirley (1991) 29 | http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.40.7922&rep=rep1&type=pdf 30 | 31 | 32 | "Random-Edge Discrepancy of Supersampling Patterns" by David Dobkin & Don Mitchel (1993) 33 | https://pdfs.semanticscholar.org/5aec/55d3f5ed875a694cc3fb6a0cee42bd8cb92d.pdf 34 | 35 | 36 | "Analysis of Forced Random Sampling" by Daniel Cornel 37 | http://drivenbynostalgia.com/files/DA.pdf 38 | 39 | # Test Results 40 | tests done: 41 | * CalculateDiscrepancy 42 | ## CalculateDiscrepancy 43 | ### Blue Noise Sequences 44 | ![blue_noise](../../../_1d/samples/blue_noise/CalculateDiscrepancy.png) 45 | ### Irrational Number Sampling 46 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/CalculateDiscrepancy.png) 47 | ### Low Discrepancy Sequences 48 | ![lds](../../../_1d/samples/lds/CalculateDiscrepancy.png) 49 | ### Regular Sampling 50 | ![regular](../../../_1d/samples/regular/CalculateDiscrepancy.png) 51 | ### Uniform Random Number Sampling 52 | ![uniform_random](../../../_1d/samples/uniform_random/CalculateDiscrepancy.png) 53 | -------------------------------------------------------------------------------- /output/_1d/tests/discrepancy/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * CalculateDiscrepancy 4 | ## CalculateDiscrepancy 5 | ### Blue Noise Sequences 6 | ![blue_noise](../../../_1d/samples/blue_noise/CalculateDiscrepancy.png) 7 | ### Irrational Number Sampling 8 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/CalculateDiscrepancy.png) 9 | ### Low Discrepancy Sequences 10 | ![lds](../../../_1d/samples/lds/CalculateDiscrepancy.png) 11 | ### Regular Sampling 12 | ![regular](../../../_1d/samples/regular/CalculateDiscrepancy.png) 13 | ### Uniform Random Number Sampling 14 | ![uniform_random](../../../_1d/samples/uniform_random/CalculateDiscrepancy.png) 15 | -------------------------------------------------------------------------------- /output/_1d/tests/integration/exp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/tests/integration/exp.png -------------------------------------------------------------------------------- /output/_1d/tests/integration/linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/tests/integration/linear.png -------------------------------------------------------------------------------- /output/_1d/tests/integration/page.md: -------------------------------------------------------------------------------- 1 | # Numerical Integration 2 | Source Code: [/src/families/_1d/tests/integration/](../../../../src/families/_1d/tests/integration/) 3 | 4 | Numerical integration is what this site is all about really, so this test is pretty important. 5 | 6 | If you have a function y=f(x) and you want to know what the area of the graph is from 0 to W, one way to do it is to take N samples of the function (plug N different values of x in to get N values of y out), where the samples are between 0 and W, and then average them. 7 | 8 | This average gives you an "average height" of the graph from 0 to W, so to get the area under the graph, you can now treat it like a rectangle where that value is the height, and W is the width. Multiply them together and you have an estimate for the area under the graph. 9 | 10 | A common way to sample is to use random numbers (white noise). When you do this, it's called monte carlo integration. 11 | 12 | You can use other sampling types though as well, such as low discrepancy sequences, and can still provably have your estimate head towards the right answer, and provably do so faster than white noise (more accuracy for the same number of samples). 13 | 14 | When the error is low enough, you can say that it has converged. 15 | 16 | This test uses each sampling type to try and integrate the following functions from 0 to 1: 17 | * Linear: y = x 18 | * Step: y = (x > 0.5) ? 1.0 : 0.0 19 | * Exp: y = e^x 20 | * Quadratic: y=-3x^2+2x+1 21 | 22 | ![Linear](linear.png) 23 | ![Step](step.png) 24 | ![Exp](exp.png) 25 | ![Quadratic](quadratic.png) 26 | 27 | ## links 28 | 29 | https://blog.demofox.org/2018/06/12/monte-carlo-integration-explanation-in-1d/ - Monte Carlo Integration Explanation in 1D. 30 | 31 | # Test Results 32 | tests done: 33 | * Linear 34 | * Step 35 | * Exp 36 | * Quadratic 37 | ## Linear 38 | ### Blue Noise Sequences 39 | ![blue_noise](../../../_1d/samples/blue_noise/Linear.png) 40 | ### Irrational Number Sampling 41 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Linear.png) 42 | ### Low Discrepancy Sequences 43 | ![lds](../../../_1d/samples/lds/Linear.png) 44 | ### Regular Sampling 45 | ![regular](../../../_1d/samples/regular/Linear.png) 46 | ### Uniform Random Number Sampling 47 | ![uniform_random](../../../_1d/samples/uniform_random/Linear.png) 48 | ## Step 49 | ### Blue Noise Sequences 50 | ![blue_noise](../../../_1d/samples/blue_noise/Step.png) 51 | ### Irrational Number Sampling 52 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Step.png) 53 | ### Low Discrepancy Sequences 54 | ![lds](../../../_1d/samples/lds/Step.png) 55 | ### Regular Sampling 56 | ![regular](../../../_1d/samples/regular/Step.png) 57 | ### Uniform Random Number Sampling 58 | ![uniform_random](../../../_1d/samples/uniform_random/Step.png) 59 | ## Exp 60 | ### Blue Noise Sequences 61 | ![blue_noise](../../../_1d/samples/blue_noise/Exp.png) 62 | ### Irrational Number Sampling 63 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Exp.png) 64 | ### Low Discrepancy Sequences 65 | ![lds](../../../_1d/samples/lds/Exp.png) 66 | ### Regular Sampling 67 | ![regular](../../../_1d/samples/regular/Exp.png) 68 | ### Uniform Random Number Sampling 69 | ![uniform_random](../../../_1d/samples/uniform_random/Exp.png) 70 | ## Quadratic 71 | ### Blue Noise Sequences 72 | ![blue_noise](../../../_1d/samples/blue_noise/Quadratic.png) 73 | ### Irrational Number Sampling 74 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Quadratic.png) 75 | ### Low Discrepancy Sequences 76 | ![lds](../../../_1d/samples/lds/Quadratic.png) 77 | ### Regular Sampling 78 | ![regular](../../../_1d/samples/regular/Quadratic.png) 79 | ### Uniform Random Number Sampling 80 | ![uniform_random](../../../_1d/samples/uniform_random/Quadratic.png) 81 | -------------------------------------------------------------------------------- /output/_1d/tests/integration/quadratic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/tests/integration/quadratic.png -------------------------------------------------------------------------------- /output/_1d/tests/integration/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * Linear 4 | * Step 5 | * Exp 6 | * Quadratic 7 | ## Linear 8 | ### Blue Noise Sequences 9 | ![blue_noise](../../../_1d/samples/blue_noise/Linear.png) 10 | ### Irrational Number Sampling 11 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Linear.png) 12 | ### Low Discrepancy Sequences 13 | ![lds](../../../_1d/samples/lds/Linear.png) 14 | ### Regular Sampling 15 | ![regular](../../../_1d/samples/regular/Linear.png) 16 | ### Uniform Random Number Sampling 17 | ![uniform_random](../../../_1d/samples/uniform_random/Linear.png) 18 | ## Step 19 | ### Blue Noise Sequences 20 | ![blue_noise](../../../_1d/samples/blue_noise/Step.png) 21 | ### Irrational Number Sampling 22 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Step.png) 23 | ### Low Discrepancy Sequences 24 | ![lds](../../../_1d/samples/lds/Step.png) 25 | ### Regular Sampling 26 | ![regular](../../../_1d/samples/regular/Step.png) 27 | ### Uniform Random Number Sampling 28 | ![uniform_random](../../../_1d/samples/uniform_random/Step.png) 29 | ## Exp 30 | ### Blue Noise Sequences 31 | ![blue_noise](../../../_1d/samples/blue_noise/Exp.png) 32 | ### Irrational Number Sampling 33 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Exp.png) 34 | ### Low Discrepancy Sequences 35 | ![lds](../../../_1d/samples/lds/Exp.png) 36 | ### Regular Sampling 37 | ![regular](../../../_1d/samples/regular/Exp.png) 38 | ### Uniform Random Number Sampling 39 | ![uniform_random](../../../_1d/samples/uniform_random/Exp.png) 40 | ## Quadratic 41 | ### Blue Noise Sequences 42 | ![blue_noise](../../../_1d/samples/blue_noise/Quadratic.png) 43 | ### Irrational Number Sampling 44 | ![irrational_numbers](../../../_1d/samples/irrational_numbers/Quadratic.png) 45 | ### Low Discrepancy Sequences 46 | ![lds](../../../_1d/samples/lds/Quadratic.png) 47 | ### Regular Sampling 48 | ![regular](../../../_1d/samples/regular/Quadratic.png) 49 | ### Uniform Random Number Sampling 50 | ![uniform_random](../../../_1d/samples/uniform_random/Quadratic.png) 51 | -------------------------------------------------------------------------------- /output/_1d/tests/integration/step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_1d/tests/integration/step.png -------------------------------------------------------------------------------- /output/_1d/tests/numberline/page.md: -------------------------------------------------------------------------------- 1 | # Numberline 2 | Source Code: [/src/families/_1d/tests/numberline/](../../../../src/families/_1d/tests/numberline/) 3 | 4 | The MakeNumberline() function makes a numberline image from the samples you give it, and writes it to disk as a png, with the specified filename. 5 | 6 | The first sample is red and the last sample is green. This lets you see the order of the samples on the numberline. 7 | # Test Results 8 | tests done: 9 | * MakeNumberline 10 | ## MakeNumberline 11 | ### Blue Noise Sequences 12 | #### BestCandidate (Progressive, Randomized) 13 | ![BestCandidate](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate.png) 14 | #### BestCandidate5 (Progressive, Randomized) 15 | ![BestCandidate5](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png) 16 | #### BestCandidate10 (Progressive, Randomized) 17 | ![BestCandidate10](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png) 18 | ### Irrational Number Sampling 19 | #### GoldenRatioZero (Progressive, Deterministic) 20 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatioZero.png) 21 | #### GoldenRatio (Progressive, Deterministic) 22 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png) 23 | #### Pi (Progressive, Deterministic) 24 | ![Pi](../../../_1d/samples/irrational_numbers/MakeNumberline_Pi.png) 25 | #### Sqrt2 (Progressive, Deterministic) 26 | ![Sqrt2](../../../_1d/samples/irrational_numbers/MakeNumberline_Sqrt2.png) 27 | ### Low Discrepancy Sequences 28 | #### Sobol (Progressive, Deterministic) 29 | ![Sobol](../../../_1d/samples/lds/MakeNumberline_Sobol.png) 30 | #### VanDerCorput2 (Progressive, Deterministic) 31 | ![VanDerCorput2](../../../_1d/samples/lds/MakeNumberline_VanDerCorput2.png) 32 | #### VanDerCorput3 (Progressive, Deterministic) 33 | ![VanDerCorput3](../../../_1d/samples/lds/MakeNumberline_VanDerCorput3.png) 34 | #### VanDerCorput5 (Progressive, Deterministic) 35 | ![VanDerCorput5](../../../_1d/samples/lds/MakeNumberline_VanDerCorput5.png) 36 | ### Regular Sampling 37 | #### Regular (Not Progressive, Deterministic) 38 | ![Regular](../../../_1d/samples/regular/MakeNumberline_Regular.png) 39 | #### RegularCentered (Not Progressive, Deterministic) 40 | ![RegularCentered](../../../_1d/samples/regular/MakeNumberline_RegularCentered.png) 41 | #### RegularCenteredOffset (Not Progressive, Deterministic) 42 | ![RegularCenteredOffset](../../../_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png) 43 | #### RegularJittered (Not Progressive, Randomized) 44 | ![RegularJittered](../../../_1d/samples/regular/MakeNumberline_RegularJittered.png) 45 | ### Uniform Random Number Sampling 46 | #### UniformRandom (Progressive, Randomized) 47 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 48 | -------------------------------------------------------------------------------- /output/_1d/tests/numberline/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * MakeNumberline 4 | ## MakeNumberline 5 | ### Blue Noise Sequences 6 | #### BestCandidate (Progressive, Randomized) 7 | ![BestCandidate](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate.png) 8 | #### BestCandidate5 (Progressive, Randomized) 9 | ![BestCandidate5](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate5.png) 10 | #### BestCandidate10 (Progressive, Randomized) 11 | ![BestCandidate10](../../../_1d/samples/blue_noise/MakeNumberline_BestCandidate10.png) 12 | ### Irrational Number Sampling 13 | #### GoldenRatioZero (Progressive, Deterministic) 14 | ![GoldenRatioZero](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatioZero.png) 15 | #### GoldenRatio (Progressive, Deterministic) 16 | ![GoldenRatio](../../../_1d/samples/irrational_numbers/MakeNumberline_GoldenRatio.png) 17 | #### Pi (Progressive, Deterministic) 18 | ![Pi](../../../_1d/samples/irrational_numbers/MakeNumberline_Pi.png) 19 | #### Sqrt2 (Progressive, Deterministic) 20 | ![Sqrt2](../../../_1d/samples/irrational_numbers/MakeNumberline_Sqrt2.png) 21 | ### Low Discrepancy Sequences 22 | #### Sobol (Progressive, Deterministic) 23 | ![Sobol](../../../_1d/samples/lds/MakeNumberline_Sobol.png) 24 | #### VanDerCorput2 (Progressive, Deterministic) 25 | ![VanDerCorput2](../../../_1d/samples/lds/MakeNumberline_VanDerCorput2.png) 26 | #### VanDerCorput3 (Progressive, Deterministic) 27 | ![VanDerCorput3](../../../_1d/samples/lds/MakeNumberline_VanDerCorput3.png) 28 | #### VanDerCorput5 (Progressive, Deterministic) 29 | ![VanDerCorput5](../../../_1d/samples/lds/MakeNumberline_VanDerCorput5.png) 30 | ### Regular Sampling 31 | #### Regular (Not Progressive, Deterministic) 32 | ![Regular](../../../_1d/samples/regular/MakeNumberline_Regular.png) 33 | #### RegularCentered (Not Progressive, Deterministic) 34 | ![RegularCentered](../../../_1d/samples/regular/MakeNumberline_RegularCentered.png) 35 | #### RegularCenteredOffset (Not Progressive, Deterministic) 36 | ![RegularCenteredOffset](../../../_1d/samples/regular/MakeNumberline_RegularCenteredOffset.png) 37 | #### RegularJittered (Not Progressive, Randomized) 38 | ![RegularJittered](../../../_1d/samples/regular/MakeNumberline_RegularJittered.png) 39 | ### Uniform Random Number Sampling 40 | #### UniformRandom (Progressive, Randomized) 41 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 42 | -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/DFT_BestCandidate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/DFT_BestCandidate.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/DFT_BestCandidate10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/DFT_BestCandidate10.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/DFT_BestCandidate5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/DFT_BestCandidate5.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/MakePlot_BestCandidate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/MakePlot_BestCandidate.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/MakePlot_BestCandidate10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/MakePlot_BestCandidate10.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/MakePlot_BestCandidate5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/MakePlot_BestCandidate5.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/blue_noise/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/page.md: -------------------------------------------------------------------------------- 1 | # Blue Noise Sequences 2 | Source Code: [src/families/_2d/samples/blue_noise/](../../../../src/families/_2d/samples/blue_noise/) 3 | 4 | Blue noise samples are randomized but roughly evenly spaced. 5 | 6 | More details: [What is Blue Noise?](../../../../doc/bluenoise.md) 7 | 8 | There are many ways to generate 2d blue noise sample points, but there currently is only one way implemented: 9 | * [Mitchell's Best Candidate](../../../../doc/bestcandidate.md) 10 | 11 | There are three variations, each using a different multiplier for the number of candidates generated compared to how many blue noise samples there already are: 1, 5 and 10. 12 | # Test Results 13 | samples tested: 14 | * BestCandidate (Progressive, Randomized) 15 | * BestCandidate5 (Progressive, Randomized) 16 | * BestCandidate10 (Progressive, Randomized) 17 | ## BestCandidate 18 | ### Discrete Fourier Transform 19 | ![BestCandidate](../../../_2d/samples/blue_noise/DFT_BestCandidate.png) 20 | ### Plot 21 | ![BestCandidate](../../../_2d/samples/blue_noise/MakePlot_BestCandidate.png) 22 | ## BestCandidate5 23 | ### Discrete Fourier Transform 24 | ![BestCandidate5](../../../_2d/samples/blue_noise/DFT_BestCandidate5.png) 25 | ### Plot 26 | ![BestCandidate5](../../../_2d/samples/blue_noise/MakePlot_BestCandidate5.png) 27 | ## BestCandidate10 28 | ### Discrete Fourier Transform 29 | ![BestCandidate10](../../../_2d/samples/blue_noise/DFT_BestCandidate10.png) 30 | ### Plot 31 | ![BestCandidate10](../../../_2d/samples/blue_noise/MakePlot_BestCandidate10.png) 32 | ## Discrepancy Test 33 | ![blue_noise](../../../_2d/samples/blue_noise/CalculateDiscrepancy.png) 34 | ## Numerical Integration 35 | ### Disk 36 | ![blue_noise](../../../_2d/samples/blue_noise/Disk.png) 37 | ### Triangle 38 | ![blue_noise](../../../_2d/samples/blue_noise/Triangle.png) 39 | ### Step 40 | ![blue_noise](../../../_2d/samples/blue_noise/Step.png) 41 | ### Gaussian 42 | ![blue_noise](../../../_2d/samples/blue_noise/Gaussian.png) 43 | ### Bilinear 44 | ![blue_noise](../../../_2d/samples/blue_noise/Bilinear.png) 45 | -------------------------------------------------------------------------------- /output/_2d/samples/blue_noise/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * BestCandidate (Progressive, Randomized) 4 | * BestCandidate5 (Progressive, Randomized) 5 | * BestCandidate10 (Progressive, Randomized) 6 | ## BestCandidate 7 | ### Discrete Fourier Transform 8 | ![BestCandidate](../../../_2d/samples/blue_noise/DFT_BestCandidate.png) 9 | ### Plot 10 | ![BestCandidate](../../../_2d/samples/blue_noise/MakePlot_BestCandidate.png) 11 | ## BestCandidate5 12 | ### Discrete Fourier Transform 13 | ![BestCandidate5](../../../_2d/samples/blue_noise/DFT_BestCandidate5.png) 14 | ### Plot 15 | ![BestCandidate5](../../../_2d/samples/blue_noise/MakePlot_BestCandidate5.png) 16 | ## BestCandidate10 17 | ### Discrete Fourier Transform 18 | ![BestCandidate10](../../../_2d/samples/blue_noise/DFT_BestCandidate10.png) 19 | ### Plot 20 | ![BestCandidate10](../../../_2d/samples/blue_noise/MakePlot_BestCandidate10.png) 21 | ## Discrepancy Test 22 | ![blue_noise](../../../_2d/samples/blue_noise/CalculateDiscrepancy.png) 23 | ## Numerical Integration 24 | ### Disk 25 | ![blue_noise](../../../_2d/samples/blue_noise/Disk.png) 26 | ### Triangle 27 | ![blue_noise](../../../_2d/samples/blue_noise/Triangle.png) 28 | ### Step 29 | ![blue_noise](../../../_2d/samples/blue_noise/Step.png) 30 | ### Gaussian 31 | ![blue_noise](../../../_2d/samples/blue_noise/Gaussian.png) 32 | ### Bilinear 33 | ![blue_noise](../../../_2d/samples/blue_noise/Bilinear.png) 34 | -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/DFT_R2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/DFT_R2.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/DFT_R2Jittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/DFT_R2Jittered.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/MakePlot_R2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/MakePlot_R2.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/MakePlot_R2Jittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/MakePlot_R2Jittered.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/irrational_numbers/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/page.md: -------------------------------------------------------------------------------- 1 | # Irrational Number Sampling 2 | Source Code: [src/families/_2d/samples/irrational_numbers/](../../../../src/families/_2d/samples/irrational_numbers/) 3 | 4 | This extends the concept of irrational numbers from 1d to 2d. 5 | 6 | Check out the 1d irrational number sequence page for an explanation of the basic idea: 7 | [1D Irrational Number Sequences](../../../2d/output/_1d/samples/irrational_numbers/page.md) 8 | 9 | There are currently two 2d irrational number sequence implementations: 10 | * R2 11 | * R2 Jittered 12 | 13 | ## R2 14 | 15 | This sequence was discovered and written about by Martin Roberts (https://twitter.com/TechSparx) at http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ 16 | 17 | R2 works by generalizing the golden ratio. 18 | 19 | Normally where the golden ratio is the positive solution to the equation x^2=x+1, R2 is based on the real (non imaginary) solution to the equation x^3=x+1. 20 | 21 | This number is also called "the plastic constant" and is approximately 1.32471795724474602596. 22 | 23 | Let's call that number "g". 24 | 25 | To calculate N 2d sampling points, you loop from 0 to N-1 and calculate it like this: 26 | * x = (index / g) % 1 27 | * y = (index / (g * g)) % 1 28 | 29 | When indexing starting at zero, the first sample will be (0,0) which we've seen hasn't worked out very well for other sequences, so you can add (0.5, 0.5) to this to make it start in the center and have better properties. 30 | 31 | That means you modify the calculations to be this: 32 | * x = (0.5 + index / g) % 1 33 | * y = (0.5 + index / (g * g)) % 1 34 | 35 | ## R2 Jittered 36 | 37 | Knowing that jittering sampling locations can give sampling sequences more blue noise type properties (such as less aliasing), Martin added some jittering to his R2 sequence with good success. He wrote up the details at http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/. 38 | 39 | ## Links 40 | 41 | https://en.wikipedia.org/wiki/Plastic_number - The Plastic Constant 42 | # Test Results 43 | samples tested: 44 | * R2 (Progressive, Deterministic) 45 | * R2Jittered (Progressive, Randomized) 46 | ## R2 47 | ### Discrete Fourier Transform 48 | ![R2](../../../_2d/samples/irrational_numbers/DFT_R2.png) 49 | ### Plot 50 | ![R2](../../../_2d/samples/irrational_numbers/MakePlot_R2.png) 51 | ## R2Jittered 52 | ### Discrete Fourier Transform 53 | ![R2Jittered](../../../_2d/samples/irrational_numbers/DFT_R2Jittered.png) 54 | ### Plot 55 | ![R2Jittered](../../../_2d/samples/irrational_numbers/MakePlot_R2Jittered.png) 56 | ## Discrepancy Test 57 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/CalculateDiscrepancy.png) 58 | ## Numerical Integration 59 | ### Disk 60 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Disk.png) 61 | ### Triangle 62 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Triangle.png) 63 | ### Step 64 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Step.png) 65 | ### Gaussian 66 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Gaussian.png) 67 | ### Bilinear 68 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Bilinear.png) 69 | -------------------------------------------------------------------------------- /output/_2d/samples/irrational_numbers/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * R2 (Progressive, Deterministic) 4 | * R2Jittered (Progressive, Randomized) 5 | ## R2 6 | ### Discrete Fourier Transform 7 | ![R2](../../../_2d/samples/irrational_numbers/DFT_R2.png) 8 | ### Plot 9 | ![R2](../../../_2d/samples/irrational_numbers/MakePlot_R2.png) 10 | ## R2Jittered 11 | ### Discrete Fourier Transform 12 | ![R2Jittered](../../../_2d/samples/irrational_numbers/DFT_R2Jittered.png) 13 | ### Plot 14 | ![R2Jittered](../../../_2d/samples/irrational_numbers/MakePlot_R2Jittered.png) 15 | ## Discrepancy Test 16 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/CalculateDiscrepancy.png) 17 | ## Numerical Integration 18 | ### Disk 19 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Disk.png) 20 | ### Triangle 21 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Triangle.png) 22 | ### Step 23 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Step.png) 24 | ### Gaussian 25 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Gaussian.png) 26 | ### Bilinear 27 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Bilinear.png) 28 | -------------------------------------------------------------------------------- /output/_2d/samples/lds/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_Halton_13_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_Halton_13_9.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_Halton_2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_Halton_2_3.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_Halton_2_3_Zero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_Halton_2_3_Zero.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_Halton_5_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_Halton_5_7.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_NRooks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_NRooks.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/DFT_Sobol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/DFT_Sobol.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_Halton_13_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_Halton_13_9.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_Halton_2_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_Halton_2_3.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_Halton_2_3_Zero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_Halton_2_3_Zero.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_Halton_5_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_Halton_5_7.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_NRooks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_NRooks.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/MakePlot_Sobol.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/MakePlot_Sobol.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/lds/page.md: -------------------------------------------------------------------------------- 1 | # Low Discrepancy Sequences 2 | Source Code: [src/families/_2d/samples/lds/](../../../../src/families/_2d/samples/lds/) 3 | 4 | This extends the concept of low discrepancy numbers from 1d to 2d. 5 | 6 | Check out the 1d low discrepancy sequence page for an explanation of the basic ideas: 7 | [1D Low Discrepancy Sequences](../../../2d/output/_1d/samples/lds/page.md) 8 | 9 | ## N-Rooks 10 | 11 | N-Rooks is a sampling pattern where you treat an NxN image as if it were a chess board. Every sampling position is a rook that could move horizontally or vertically, and should be placed such that none of these rooks could capture / "see" any of the other rooks. 12 | 13 | In other words, every column has a single sample point in it, and every row has a single sample point in it. 14 | 15 | An easy way to do this is to start by having a diagonal line of the rooks like (0,0) (1,1) (2,2) ... (N-1, N1), and then randomly shuffling the rows. 16 | 17 | While this sampling pattern is randomized pretty heavily using white noise, the 1d projections of this pattern on the X and Y axis have no overlap and are a shuffle, making it better than white noise and also pretty easy to generate. 18 | 19 | 20 | 21 | 22 | TODO: finish this page! 23 | # Test Results 24 | samples tested: 25 | * NRooks (Not Progressive, Randomized) 26 | * Sobol (Progressive, Deterministic) 27 | * Halton_2_3_Zero (Progressive, Deterministic) 28 | * Halton_2_3 (Progressive, Deterministic) 29 | * Halton_5_7 (Progressive, Deterministic) 30 | * Halton_13_9 (Progressive, Deterministic) 31 | ## NRooks 32 | ### Discrete Fourier Transform 33 | ![NRooks](../../../_2d/samples/lds/DFT_NRooks.png) 34 | ### Plot 35 | ![NRooks](../../../_2d/samples/lds/MakePlot_NRooks.png) 36 | ## Sobol 37 | ### Discrete Fourier Transform 38 | ![Sobol](../../../_2d/samples/lds/DFT_Sobol.png) 39 | ### Plot 40 | ![Sobol](../../../_2d/samples/lds/MakePlot_Sobol.png) 41 | ## Halton_2_3_Zero 42 | ### Discrete Fourier Transform 43 | ![Halton_2_3_Zero](../../../_2d/samples/lds/DFT_Halton_2_3_Zero.png) 44 | ### Plot 45 | ![Halton_2_3_Zero](../../../_2d/samples/lds/MakePlot_Halton_2_3_Zero.png) 46 | ## Halton_2_3 47 | ### Discrete Fourier Transform 48 | ![Halton_2_3](../../../_2d/samples/lds/DFT_Halton_2_3.png) 49 | ### Plot 50 | ![Halton_2_3](../../../_2d/samples/lds/MakePlot_Halton_2_3.png) 51 | ## Halton_5_7 52 | ### Discrete Fourier Transform 53 | ![Halton_5_7](../../../_2d/samples/lds/DFT_Halton_5_7.png) 54 | ### Plot 55 | ![Halton_5_7](../../../_2d/samples/lds/MakePlot_Halton_5_7.png) 56 | ## Halton_13_9 57 | ### Discrete Fourier Transform 58 | ![Halton_13_9](../../../_2d/samples/lds/DFT_Halton_13_9.png) 59 | ### Plot 60 | ![Halton_13_9](../../../_2d/samples/lds/MakePlot_Halton_13_9.png) 61 | ## Discrepancy Test 62 | ![lds](../../../_2d/samples/lds/CalculateDiscrepancy.png) 63 | ## Numerical Integration 64 | ### Disk 65 | ![lds](../../../_2d/samples/lds/Disk.png) 66 | ### Triangle 67 | ![lds](../../../_2d/samples/lds/Triangle.png) 68 | ### Step 69 | ![lds](../../../_2d/samples/lds/Step.png) 70 | ### Gaussian 71 | ![lds](../../../_2d/samples/lds/Gaussian.png) 72 | ### Bilinear 73 | ![lds](../../../_2d/samples/lds/Bilinear.png) 74 | -------------------------------------------------------------------------------- /output/_2d/samples/lds/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * NRooks (Not Progressive, Randomized) 4 | * Sobol (Progressive, Deterministic) 5 | * Halton_2_3_Zero (Progressive, Deterministic) 6 | * Halton_2_3 (Progressive, Deterministic) 7 | * Halton_5_7 (Progressive, Deterministic) 8 | * Halton_13_9 (Progressive, Deterministic) 9 | ## NRooks 10 | ### Discrete Fourier Transform 11 | ![NRooks](../../../_2d/samples/lds/DFT_NRooks.png) 12 | ### Plot 13 | ![NRooks](../../../_2d/samples/lds/MakePlot_NRooks.png) 14 | ## Sobol 15 | ### Discrete Fourier Transform 16 | ![Sobol](../../../_2d/samples/lds/DFT_Sobol.png) 17 | ### Plot 18 | ![Sobol](../../../_2d/samples/lds/MakePlot_Sobol.png) 19 | ## Halton_2_3_Zero 20 | ### Discrete Fourier Transform 21 | ![Halton_2_3_Zero](../../../_2d/samples/lds/DFT_Halton_2_3_Zero.png) 22 | ### Plot 23 | ![Halton_2_3_Zero](../../../_2d/samples/lds/MakePlot_Halton_2_3_Zero.png) 24 | ## Halton_2_3 25 | ### Discrete Fourier Transform 26 | ![Halton_2_3](../../../_2d/samples/lds/DFT_Halton_2_3.png) 27 | ### Plot 28 | ![Halton_2_3](../../../_2d/samples/lds/MakePlot_Halton_2_3.png) 29 | ## Halton_5_7 30 | ### Discrete Fourier Transform 31 | ![Halton_5_7](../../../_2d/samples/lds/DFT_Halton_5_7.png) 32 | ### Plot 33 | ![Halton_5_7](../../../_2d/samples/lds/MakePlot_Halton_5_7.png) 34 | ## Halton_13_9 35 | ### Discrete Fourier Transform 36 | ![Halton_13_9](../../../_2d/samples/lds/DFT_Halton_13_9.png) 37 | ### Plot 38 | ![Halton_13_9](../../../_2d/samples/lds/MakePlot_Halton_13_9.png) 39 | ## Discrepancy Test 40 | ![lds](../../../_2d/samples/lds/CalculateDiscrepancy.png) 41 | ## Numerical Integration 42 | ### Disk 43 | ![lds](../../../_2d/samples/lds/Disk.png) 44 | ### Triangle 45 | ![lds](../../../_2d/samples/lds/Triangle.png) 46 | ### Step 47 | ![lds](../../../_2d/samples/lds/Step.png) 48 | ### Gaussian 49 | ![lds](../../../_2d/samples/lds/Gaussian.png) 50 | ### Bilinear 51 | ![lds](../../../_2d/samples/lds/Bilinear.png) 52 | -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2NoOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2NoOffset.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2_1Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2_1Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2_2Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2_2Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2_3Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2_3Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley2_4Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley2_4Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley3.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/DFT_Hammersley5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/DFT_Hammersley5.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2NoOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2NoOffset.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_1Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_1Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_2Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_2Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_3Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_3Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_4Bit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley2_4Bit.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley3.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/MakePlot_Hammersley5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/MakePlot_Hammersley5.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/lds_hammersley/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/lds_hammersley/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * Hammersley2NoOffset (Not Progressive, Deterministic) 4 | * Hammersley2 (Not Progressive, Deterministic) 5 | * Hammersley3 (Not Progressive, Deterministic) 6 | * Hammersley5 (Not Progressive, Deterministic) 7 | * Hammersley2_1Bit (Not Progressive, Deterministic) 8 | * Hammersley2_2Bit (Not Progressive, Deterministic) 9 | * Hammersley2_3Bit (Not Progressive, Deterministic) 10 | * Hammersley2_4Bit (Not Progressive, Deterministic) 11 | ## Hammersley2NoOffset 12 | ### Discrete Fourier Transform 13 | ![Hammersley2NoOffset](../../../_2d/samples/lds_hammersley/DFT_Hammersley2NoOffset.png) 14 | ### Plot 15 | ![Hammersley2NoOffset](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2NoOffset.png) 16 | ## Hammersley2 17 | ### Discrete Fourier Transform 18 | ![Hammersley2](../../../_2d/samples/lds_hammersley/DFT_Hammersley2.png) 19 | ### Plot 20 | ![Hammersley2](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2.png) 21 | ## Hammersley3 22 | ### Discrete Fourier Transform 23 | ![Hammersley3](../../../_2d/samples/lds_hammersley/DFT_Hammersley3.png) 24 | ### Plot 25 | ![Hammersley3](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley3.png) 26 | ## Hammersley5 27 | ### Discrete Fourier Transform 28 | ![Hammersley5](../../../_2d/samples/lds_hammersley/DFT_Hammersley5.png) 29 | ### Plot 30 | ![Hammersley5](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley5.png) 31 | ## Hammersley2_1Bit 32 | ### Discrete Fourier Transform 33 | ![Hammersley2_1Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_1Bit.png) 34 | ### Plot 35 | ![Hammersley2_1Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_1Bit.png) 36 | ## Hammersley2_2Bit 37 | ### Discrete Fourier Transform 38 | ![Hammersley2_2Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_2Bit.png) 39 | ### Plot 40 | ![Hammersley2_2Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_2Bit.png) 41 | ## Hammersley2_3Bit 42 | ### Discrete Fourier Transform 43 | ![Hammersley2_3Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_3Bit.png) 44 | ### Plot 45 | ![Hammersley2_3Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_3Bit.png) 46 | ## Hammersley2_4Bit 47 | ### Discrete Fourier Transform 48 | ![Hammersley2_4Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_4Bit.png) 49 | ### Plot 50 | ![Hammersley2_4Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_4Bit.png) 51 | ## Discrepancy Test 52 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/CalculateDiscrepancy.png) 53 | ## Numerical Integration 54 | ### Disk 55 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Disk.png) 56 | ### Triangle 57 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Triangle.png) 58 | ### Step 59 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Step.png) 60 | ### Gaussian 61 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Gaussian.png) 62 | ### Bilinear 63 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Bilinear.png) 64 | -------------------------------------------------------------------------------- /output/_2d/samples/regular/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/DFT_Regular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/DFT_Regular.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/DFT_RegularCentered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/DFT_RegularCentered.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/DFT_RegularCenteredOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/DFT_RegularCenteredOffset.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/DFT_RegularJittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/DFT_RegularJittered.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/MakePlot_Regular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/MakePlot_Regular.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/MakePlot_RegularCentered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/MakePlot_RegularCentered.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/MakePlot_RegularCenteredOffset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/MakePlot_RegularCenteredOffset.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/MakePlot_RegularJittered.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/MakePlot_RegularJittered.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/regular/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/regular/page.md: -------------------------------------------------------------------------------- 1 | # Regular Sampling 2 | Source Code: [src/families/_2d/samples/regular/](../../../../src/families/_2d/samples/regular/) 3 | 4 | The 2d regular sampling sequences are direct extensions of the 1d regular sampling sequences. 5 | 6 | [1D Regular Sampling](../../../_1d/samples/regular/page.md) 7 | 8 | It might be odd to see that RegularJittered has the lowest discrepancy of these sequences, but discrepancy gets a bit more complex in 2d. Basically, those big empty rows and columns between samples in regular sampling contribute to making larger discrepancy for those sequences. Adding random jitter causes those regions to get broken up. 9 | 10 | The lower discrepancy means that it also does better at integration. 11 | 12 | # Test Results 13 | samples tested: 14 | * Regular (Not Progressive, Deterministic) 15 | * RegularCentered (Not Progressive, Deterministic) 16 | * RegularCenteredOffset (Not Progressive, Deterministic) 17 | * RegularJittered (Not Progressive, Randomized) 18 | ## Regular 19 | ### Discrete Fourier Transform 20 | ![Regular](../../../_2d/samples/regular/DFT_Regular.png) 21 | ### Plot 22 | ![Regular](../../../_2d/samples/regular/MakePlot_Regular.png) 23 | ## RegularCentered 24 | ### Discrete Fourier Transform 25 | ![RegularCentered](../../../_2d/samples/regular/DFT_RegularCentered.png) 26 | ### Plot 27 | ![RegularCentered](../../../_2d/samples/regular/MakePlot_RegularCentered.png) 28 | ## RegularCenteredOffset 29 | ### Discrete Fourier Transform 30 | ![RegularCenteredOffset](../../../_2d/samples/regular/DFT_RegularCenteredOffset.png) 31 | ### Plot 32 | ![RegularCenteredOffset](../../../_2d/samples/regular/MakePlot_RegularCenteredOffset.png) 33 | ## RegularJittered 34 | ### Discrete Fourier Transform 35 | ![RegularJittered](../../../_2d/samples/regular/DFT_RegularJittered.png) 36 | ### Plot 37 | ![RegularJittered](../../../_2d/samples/regular/MakePlot_RegularJittered.png) 38 | ## Discrepancy Test 39 | ![regular](../../../_2d/samples/regular/CalculateDiscrepancy.png) 40 | ## Numerical Integration 41 | ### Disk 42 | ![regular](../../../_2d/samples/regular/Disk.png) 43 | ### Triangle 44 | ![regular](../../../_2d/samples/regular/Triangle.png) 45 | ### Step 46 | ![regular](../../../_2d/samples/regular/Step.png) 47 | ### Gaussian 48 | ![regular](../../../_2d/samples/regular/Gaussian.png) 49 | ### Bilinear 50 | ![regular](../../../_2d/samples/regular/Bilinear.png) 51 | -------------------------------------------------------------------------------- /output/_2d/samples/regular/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * Regular (Not Progressive, Deterministic) 4 | * RegularCentered (Not Progressive, Deterministic) 5 | * RegularCenteredOffset (Not Progressive, Deterministic) 6 | * RegularJittered (Not Progressive, Randomized) 7 | ## Regular 8 | ### Discrete Fourier Transform 9 | ![Regular](../../../_2d/samples/regular/DFT_Regular.png) 10 | ### Plot 11 | ![Regular](../../../_2d/samples/regular/MakePlot_Regular.png) 12 | ## RegularCentered 13 | ### Discrete Fourier Transform 14 | ![RegularCentered](../../../_2d/samples/regular/DFT_RegularCentered.png) 15 | ### Plot 16 | ![RegularCentered](../../../_2d/samples/regular/MakePlot_RegularCentered.png) 17 | ## RegularCenteredOffset 18 | ### Discrete Fourier Transform 19 | ![RegularCenteredOffset](../../../_2d/samples/regular/DFT_RegularCenteredOffset.png) 20 | ### Plot 21 | ![RegularCenteredOffset](../../../_2d/samples/regular/MakePlot_RegularCenteredOffset.png) 22 | ## RegularJittered 23 | ### Discrete Fourier Transform 24 | ![RegularJittered](../../../_2d/samples/regular/DFT_RegularJittered.png) 25 | ### Plot 26 | ![RegularJittered](../../../_2d/samples/regular/MakePlot_RegularJittered.png) 27 | ## Discrepancy Test 28 | ![regular](../../../_2d/samples/regular/CalculateDiscrepancy.png) 29 | ## Numerical Integration 30 | ### Disk 31 | ![regular](../../../_2d/samples/regular/Disk.png) 32 | ### Triangle 33 | ![regular](../../../_2d/samples/regular/Triangle.png) 34 | ### Step 35 | ![regular](../../../_2d/samples/regular/Step.png) 36 | ### Gaussian 37 | ![regular](../../../_2d/samples/regular/Gaussian.png) 38 | ### Bilinear 39 | ![regular](../../../_2d/samples/regular/Bilinear.png) 40 | -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/Bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/Bilinear.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/CalculateDiscrepancy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/CalculateDiscrepancy.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/DFT_UniformRandom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/DFT_UniformRandom.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/Disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/Disk.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/Gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/Gaussian.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/MakePlot_UniformRandom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/MakePlot_UniformRandom.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/Step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/Step.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/Triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/samples/uniform_random/Triangle.png -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/page.md: -------------------------------------------------------------------------------- 1 | # Uniform Random Number Sampling 2 | Source Code: [src/families/_2d/samples/uniform_random/](../../../../src/families/_2d/samples/uniform_random/) 3 | 4 | Uniform random sampling in 2d is exactly the same as uniform random sampling in 1d with very similar properties. 5 | 6 | [1D Regular Sampling](../../../_1d/samples/uniform_random/page.md) 7 | # Test Results 8 | samples tested: 9 | * UniformRandom (Progressive, Randomized) 10 | ## UniformRandom 11 | ### Discrete Fourier Transform 12 | ![UniformRandom](../../../_2d/samples/uniform_random/DFT_UniformRandom.png) 13 | ### Plot 14 | ![UniformRandom](../../../_2d/samples/uniform_random/MakePlot_UniformRandom.png) 15 | ## Discrepancy Test 16 | ![uniform_random](../../../_2d/samples/uniform_random/CalculateDiscrepancy.png) 17 | ## Numerical Integration 18 | ### Disk 19 | ![uniform_random](../../../_2d/samples/uniform_random/Disk.png) 20 | ### Triangle 21 | ![uniform_random](../../../_2d/samples/uniform_random/Triangle.png) 22 | ### Step 23 | ![uniform_random](../../../_2d/samples/uniform_random/Step.png) 24 | ### Gaussian 25 | ![uniform_random](../../../_2d/samples/uniform_random/Gaussian.png) 26 | ### Bilinear 27 | ![uniform_random](../../../_2d/samples/uniform_random/Bilinear.png) 28 | -------------------------------------------------------------------------------- /output/_2d/samples/uniform_random/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | samples tested: 3 | * UniformRandom (Progressive, Randomized) 4 | ## UniformRandom 5 | ### Discrete Fourier Transform 6 | ![UniformRandom](../../../_2d/samples/uniform_random/DFT_UniformRandom.png) 7 | ### Plot 8 | ![UniformRandom](../../../_2d/samples/uniform_random/MakePlot_UniformRandom.png) 9 | ## Discrepancy Test 10 | ![uniform_random](../../../_2d/samples/uniform_random/CalculateDiscrepancy.png) 11 | ## Numerical Integration 12 | ### Disk 13 | ![uniform_random](../../../_2d/samples/uniform_random/Disk.png) 14 | ### Triangle 15 | ![uniform_random](../../../_2d/samples/uniform_random/Triangle.png) 16 | ### Step 17 | ![uniform_random](../../../_2d/samples/uniform_random/Step.png) 18 | ### Gaussian 19 | ![uniform_random](../../../_2d/samples/uniform_random/Gaussian.png) 20 | ### Bilinear 21 | ![uniform_random](../../../_2d/samples/uniform_random/Bilinear.png) 22 | -------------------------------------------------------------------------------- /output/_2d/tests/dft/page.md: -------------------------------------------------------------------------------- 1 | # Discrete Fourier Transform 2 | Source Code: [/src/families/_2d/tests/dft/](../../../../src/families/_2d/tests/dft/) 3 | 4 | This is the same as the 1d DFT test, but in 2d. The center of the image is 0hz. 5 | 6 | [1D DFT Test](../../../_1d/tests/dft/page.md) 7 | 8 | Nothing special is done for randomized vs deterministic sequences, or progressive vs non progressive sequences. 9 | # Test Results 10 | tests done: 11 | * DFT 12 | ## DFT 13 | ### Blue Noise Sequences 14 | #### BestCandidate (Progressive, Randomized) 15 | ![BestCandidate](../../../_2d/samples/blue_noise/DFT_BestCandidate.png) 16 | #### BestCandidate5 (Progressive, Randomized) 17 | ![BestCandidate5](../../../_2d/samples/blue_noise/DFT_BestCandidate5.png) 18 | #### BestCandidate10 (Progressive, Randomized) 19 | ![BestCandidate10](../../../_2d/samples/blue_noise/DFT_BestCandidate10.png) 20 | ### Irrational Number Sampling 21 | #### R2 (Progressive, Deterministic) 22 | ![R2](../../../_2d/samples/irrational_numbers/DFT_R2.png) 23 | #### R2Jittered (Progressive, Randomized) 24 | ![R2Jittered](../../../_2d/samples/irrational_numbers/DFT_R2Jittered.png) 25 | ### Low Discrepancy Sequences 26 | #### NRooks (Not Progressive, Randomized) 27 | ![NRooks](../../../_2d/samples/lds/DFT_NRooks.png) 28 | #### Sobol (Progressive, Deterministic) 29 | ![Sobol](../../../_2d/samples/lds/DFT_Sobol.png) 30 | #### Halton_2_3_Zero (Progressive, Deterministic) 31 | ![Halton_2_3_Zero](../../../_2d/samples/lds/DFT_Halton_2_3_Zero.png) 32 | #### Halton_2_3 (Progressive, Deterministic) 33 | ![Halton_2_3](../../../_2d/samples/lds/DFT_Halton_2_3.png) 34 | #### Halton_5_7 (Progressive, Deterministic) 35 | ![Halton_5_7](../../../_2d/samples/lds/DFT_Halton_5_7.png) 36 | #### Halton_13_9 (Progressive, Deterministic) 37 | ![Halton_13_9](../../../_2d/samples/lds/DFT_Halton_13_9.png) 38 | ### Hammersley Low Discrepancy Sequence 39 | #### Hammersley2NoOffset (Not Progressive, Deterministic) 40 | ![Hammersley2NoOffset](../../../_2d/samples/lds_hammersley/DFT_Hammersley2NoOffset.png) 41 | #### Hammersley2 (Not Progressive, Deterministic) 42 | ![Hammersley2](../../../_2d/samples/lds_hammersley/DFT_Hammersley2.png) 43 | #### Hammersley3 (Not Progressive, Deterministic) 44 | ![Hammersley3](../../../_2d/samples/lds_hammersley/DFT_Hammersley3.png) 45 | #### Hammersley5 (Not Progressive, Deterministic) 46 | ![Hammersley5](../../../_2d/samples/lds_hammersley/DFT_Hammersley5.png) 47 | #### Hammersley2_1Bit (Not Progressive, Deterministic) 48 | ![Hammersley2_1Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_1Bit.png) 49 | #### Hammersley2_2Bit (Not Progressive, Deterministic) 50 | ![Hammersley2_2Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_2Bit.png) 51 | #### Hammersley2_3Bit (Not Progressive, Deterministic) 52 | ![Hammersley2_3Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_3Bit.png) 53 | #### Hammersley2_4Bit (Not Progressive, Deterministic) 54 | ![Hammersley2_4Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_4Bit.png) 55 | ### Regular Sampling 56 | #### Regular (Not Progressive, Deterministic) 57 | ![Regular](../../../_2d/samples/regular/DFT_Regular.png) 58 | #### RegularCentered (Not Progressive, Deterministic) 59 | ![RegularCentered](../../../_2d/samples/regular/DFT_RegularCentered.png) 60 | #### RegularCenteredOffset (Not Progressive, Deterministic) 61 | ![RegularCenteredOffset](../../../_2d/samples/regular/DFT_RegularCenteredOffset.png) 62 | #### RegularJittered (Not Progressive, Randomized) 63 | ![RegularJittered](../../../_2d/samples/regular/DFT_RegularJittered.png) 64 | ### Uniform Random Number Sampling 65 | #### UniformRandom (Progressive, Randomized) 66 | ![UniformRandom](../../../_2d/samples/uniform_random/DFT_UniformRandom.png) 67 | -------------------------------------------------------------------------------- /output/_2d/tests/dft/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * DFT 4 | ## DFT 5 | ### Blue Noise Sequences 6 | #### BestCandidate (Progressive, Randomized) 7 | ![BestCandidate](../../../_2d/samples/blue_noise/DFT_BestCandidate.png) 8 | #### BestCandidate5 (Progressive, Randomized) 9 | ![BestCandidate5](../../../_2d/samples/blue_noise/DFT_BestCandidate5.png) 10 | #### BestCandidate10 (Progressive, Randomized) 11 | ![BestCandidate10](../../../_2d/samples/blue_noise/DFT_BestCandidate10.png) 12 | ### Irrational Number Sampling 13 | #### R2 (Progressive, Deterministic) 14 | ![R2](../../../_2d/samples/irrational_numbers/DFT_R2.png) 15 | #### R2Jittered (Progressive, Randomized) 16 | ![R2Jittered](../../../_2d/samples/irrational_numbers/DFT_R2Jittered.png) 17 | ### Low Discrepancy Sequences 18 | #### NRooks (Not Progressive, Randomized) 19 | ![NRooks](../../../_2d/samples/lds/DFT_NRooks.png) 20 | #### Sobol (Progressive, Deterministic) 21 | ![Sobol](../../../_2d/samples/lds/DFT_Sobol.png) 22 | #### Halton_2_3_Zero (Progressive, Deterministic) 23 | ![Halton_2_3_Zero](../../../_2d/samples/lds/DFT_Halton_2_3_Zero.png) 24 | #### Halton_2_3 (Progressive, Deterministic) 25 | ![Halton_2_3](../../../_2d/samples/lds/DFT_Halton_2_3.png) 26 | #### Halton_5_7 (Progressive, Deterministic) 27 | ![Halton_5_7](../../../_2d/samples/lds/DFT_Halton_5_7.png) 28 | #### Halton_13_9 (Progressive, Deterministic) 29 | ![Halton_13_9](../../../_2d/samples/lds/DFT_Halton_13_9.png) 30 | ### Hammersley Low Discrepancy Sequence 31 | #### Hammersley2NoOffset (Not Progressive, Deterministic) 32 | ![Hammersley2NoOffset](../../../_2d/samples/lds_hammersley/DFT_Hammersley2NoOffset.png) 33 | #### Hammersley2 (Not Progressive, Deterministic) 34 | ![Hammersley2](../../../_2d/samples/lds_hammersley/DFT_Hammersley2.png) 35 | #### Hammersley3 (Not Progressive, Deterministic) 36 | ![Hammersley3](../../../_2d/samples/lds_hammersley/DFT_Hammersley3.png) 37 | #### Hammersley5 (Not Progressive, Deterministic) 38 | ![Hammersley5](../../../_2d/samples/lds_hammersley/DFT_Hammersley5.png) 39 | #### Hammersley2_1Bit (Not Progressive, Deterministic) 40 | ![Hammersley2_1Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_1Bit.png) 41 | #### Hammersley2_2Bit (Not Progressive, Deterministic) 42 | ![Hammersley2_2Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_2Bit.png) 43 | #### Hammersley2_3Bit (Not Progressive, Deterministic) 44 | ![Hammersley2_3Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_3Bit.png) 45 | #### Hammersley2_4Bit (Not Progressive, Deterministic) 46 | ![Hammersley2_4Bit](../../../_2d/samples/lds_hammersley/DFT_Hammersley2_4Bit.png) 47 | ### Regular Sampling 48 | #### Regular (Not Progressive, Deterministic) 49 | ![Regular](../../../_2d/samples/regular/DFT_Regular.png) 50 | #### RegularCentered (Not Progressive, Deterministic) 51 | ![RegularCentered](../../../_2d/samples/regular/DFT_RegularCentered.png) 52 | #### RegularCenteredOffset (Not Progressive, Deterministic) 53 | ![RegularCenteredOffset](../../../_2d/samples/regular/DFT_RegularCenteredOffset.png) 54 | #### RegularJittered (Not Progressive, Randomized) 55 | ![RegularJittered](../../../_2d/samples/regular/DFT_RegularJittered.png) 56 | ### Uniform Random Number Sampling 57 | #### UniformRandom (Progressive, Randomized) 58 | ![UniformRandom](../../../_2d/samples/uniform_random/DFT_UniformRandom.png) 59 | -------------------------------------------------------------------------------- /output/_2d/tests/discrepancy/page.md: -------------------------------------------------------------------------------- 1 | # Discrepancy Test 2 | Source Code: [/src/families/_2d/tests/discrepancy/](../../../../src/families/_2d/tests/discrepancy/) 3 | 4 | This is the same as the 1d discrepancy test, but in 2d. 5 | 6 | [1D Discrepancy Test](../../../_1d/tests/discrepancy/page.md) 7 | 8 | Calculating discrepancy gets a lot more expensive each dimension you go up. 9 | 10 | In 1d, it's an O(n^2) operation, but in 2d, it's an O(n^4) operation. This is because in 1d, you have to consider every pair of points (n^2), but in higher dimensions you have to do the same, but on each axis individually. 11 | 12 | Intuition about discrepancy changes as you go up in dimension as well. What had low discrepancy in 1d may not have low discrepancy in 2d and higher. For instance, in 1d, regular sampling had the lowest discrepancy, but in 2d (and up), that isn't the case due to those long rows and columns of empty space between the sampling points. 13 | 14 | Blue noise has lower discrepancy than regular sampling in 2d, as does regular jittered sampling. Neither of those things are true in 1d. 15 | 16 | This difference in discrepancy also affects how well the sequences perform for integration. 17 | 18 | # Test Results 19 | tests done: 20 | * CalculateDiscrepancy 21 | ## CalculateDiscrepancy 22 | ### Blue Noise Sequences 23 | ![blue_noise](../../../_2d/samples/blue_noise/CalculateDiscrepancy.png) 24 | ### Irrational Number Sampling 25 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/CalculateDiscrepancy.png) 26 | ### Low Discrepancy Sequences 27 | ![lds](../../../_2d/samples/lds/CalculateDiscrepancy.png) 28 | ### Hammersley Low Discrepancy Sequence 29 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/CalculateDiscrepancy.png) 30 | ### Regular Sampling 31 | ![regular](../../../_2d/samples/regular/CalculateDiscrepancy.png) 32 | ### Uniform Random Number Sampling 33 | ![uniform_random](../../../_2d/samples/uniform_random/CalculateDiscrepancy.png) 34 | -------------------------------------------------------------------------------- /output/_2d/tests/discrepancy/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * CalculateDiscrepancy 4 | ## CalculateDiscrepancy 5 | ### Blue Noise Sequences 6 | ![blue_noise](../../../_2d/samples/blue_noise/CalculateDiscrepancy.png) 7 | ### Irrational Number Sampling 8 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/CalculateDiscrepancy.png) 9 | ### Low Discrepancy Sequences 10 | ![lds](../../../_2d/samples/lds/CalculateDiscrepancy.png) 11 | ### Hammersley Low Discrepancy Sequence 12 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/CalculateDiscrepancy.png) 13 | ### Regular Sampling 14 | ![regular](../../../_2d/samples/regular/CalculateDiscrepancy.png) 15 | ### Uniform Random Number Sampling 16 | ![uniform_random](../../../_2d/samples/uniform_random/CalculateDiscrepancy.png) 17 | -------------------------------------------------------------------------------- /output/_2d/tests/integration/bilinear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/tests/integration/bilinear.png -------------------------------------------------------------------------------- /output/_2d/tests/integration/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/tests/integration/disk.png -------------------------------------------------------------------------------- /output/_2d/tests/integration/gaussian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/tests/integration/gaussian.png -------------------------------------------------------------------------------- /output/_2d/tests/integration/page.md: -------------------------------------------------------------------------------- 1 | # Numerical Integration 2 | Source Code: [/src/families/_2d/tests/integration/](../../../../src/families/_2d/tests/integration/) 3 | 4 | This is the same as the 1d integration test, but integrating over 2d functions instead of 1d functions. 5 | 6 | [1D Integration Test](../../../_1d/tests/integration/page.md) 7 | 8 | The functions being integrated over are: 9 | * Disk: the inside of a circle with radius 2/pi 10 | * Triangle: y > x 11 | * Step: x < 1/pi 12 | * Gaussian: z = e^(-x^2-y^2) 13 | * Bilinear: z = x * y 14 | 15 | ![Disk](disk.png) 16 | ![Triangle](triangle.png) 17 | ![Step](step.png) 18 | ![Gaussian](gaussian.png) 19 | ![Bilinear](bilinear.png) 20 | 21 | # Test Results 22 | tests done: 23 | * Disk 24 | * Triangle 25 | * Step 26 | * Gaussian 27 | * Bilinear 28 | ## Disk 29 | ### Blue Noise Sequences 30 | ![blue_noise](../../../_2d/samples/blue_noise/Disk.png) 31 | ### Irrational Number Sampling 32 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Disk.png) 33 | ### Low Discrepancy Sequences 34 | ![lds](../../../_2d/samples/lds/Disk.png) 35 | ### Hammersley Low Discrepancy Sequence 36 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Disk.png) 37 | ### Regular Sampling 38 | ![regular](../../../_2d/samples/regular/Disk.png) 39 | ### Uniform Random Number Sampling 40 | ![uniform_random](../../../_2d/samples/uniform_random/Disk.png) 41 | ## Triangle 42 | ### Blue Noise Sequences 43 | ![blue_noise](../../../_2d/samples/blue_noise/Triangle.png) 44 | ### Irrational Number Sampling 45 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Triangle.png) 46 | ### Low Discrepancy Sequences 47 | ![lds](../../../_2d/samples/lds/Triangle.png) 48 | ### Hammersley Low Discrepancy Sequence 49 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Triangle.png) 50 | ### Regular Sampling 51 | ![regular](../../../_2d/samples/regular/Triangle.png) 52 | ### Uniform Random Number Sampling 53 | ![uniform_random](../../../_2d/samples/uniform_random/Triangle.png) 54 | ## Step 55 | ### Blue Noise Sequences 56 | ![blue_noise](../../../_2d/samples/blue_noise/Step.png) 57 | ### Irrational Number Sampling 58 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Step.png) 59 | ### Low Discrepancy Sequences 60 | ![lds](../../../_2d/samples/lds/Step.png) 61 | ### Hammersley Low Discrepancy Sequence 62 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Step.png) 63 | ### Regular Sampling 64 | ![regular](../../../_2d/samples/regular/Step.png) 65 | ### Uniform Random Number Sampling 66 | ![uniform_random](../../../_2d/samples/uniform_random/Step.png) 67 | ## Gaussian 68 | ### Blue Noise Sequences 69 | ![blue_noise](../../../_2d/samples/blue_noise/Gaussian.png) 70 | ### Irrational Number Sampling 71 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Gaussian.png) 72 | ### Low Discrepancy Sequences 73 | ![lds](../../../_2d/samples/lds/Gaussian.png) 74 | ### Hammersley Low Discrepancy Sequence 75 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Gaussian.png) 76 | ### Regular Sampling 77 | ![regular](../../../_2d/samples/regular/Gaussian.png) 78 | ### Uniform Random Number Sampling 79 | ![uniform_random](../../../_2d/samples/uniform_random/Gaussian.png) 80 | ## Bilinear 81 | ### Blue Noise Sequences 82 | ![blue_noise](../../../_2d/samples/blue_noise/Bilinear.png) 83 | ### Irrational Number Sampling 84 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Bilinear.png) 85 | ### Low Discrepancy Sequences 86 | ![lds](../../../_2d/samples/lds/Bilinear.png) 87 | ### Hammersley Low Discrepancy Sequence 88 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Bilinear.png) 89 | ### Regular Sampling 90 | ![regular](../../../_2d/samples/regular/Bilinear.png) 91 | ### Uniform Random Number Sampling 92 | ![uniform_random](../../../_2d/samples/uniform_random/Bilinear.png) 93 | -------------------------------------------------------------------------------- /output/_2d/tests/integration/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * Disk 4 | * Triangle 5 | * Step 6 | * Gaussian 7 | * Bilinear 8 | ## Disk 9 | ### Blue Noise Sequences 10 | ![blue_noise](../../../_2d/samples/blue_noise/Disk.png) 11 | ### Irrational Number Sampling 12 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Disk.png) 13 | ### Low Discrepancy Sequences 14 | ![lds](../../../_2d/samples/lds/Disk.png) 15 | ### Hammersley Low Discrepancy Sequence 16 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Disk.png) 17 | ### Regular Sampling 18 | ![regular](../../../_2d/samples/regular/Disk.png) 19 | ### Uniform Random Number Sampling 20 | ![uniform_random](../../../_2d/samples/uniform_random/Disk.png) 21 | ## Triangle 22 | ### Blue Noise Sequences 23 | ![blue_noise](../../../_2d/samples/blue_noise/Triangle.png) 24 | ### Irrational Number Sampling 25 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Triangle.png) 26 | ### Low Discrepancy Sequences 27 | ![lds](../../../_2d/samples/lds/Triangle.png) 28 | ### Hammersley Low Discrepancy Sequence 29 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Triangle.png) 30 | ### Regular Sampling 31 | ![regular](../../../_2d/samples/regular/Triangle.png) 32 | ### Uniform Random Number Sampling 33 | ![uniform_random](../../../_2d/samples/uniform_random/Triangle.png) 34 | ## Step 35 | ### Blue Noise Sequences 36 | ![blue_noise](../../../_2d/samples/blue_noise/Step.png) 37 | ### Irrational Number Sampling 38 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Step.png) 39 | ### Low Discrepancy Sequences 40 | ![lds](../../../_2d/samples/lds/Step.png) 41 | ### Hammersley Low Discrepancy Sequence 42 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Step.png) 43 | ### Regular Sampling 44 | ![regular](../../../_2d/samples/regular/Step.png) 45 | ### Uniform Random Number Sampling 46 | ![uniform_random](../../../_2d/samples/uniform_random/Step.png) 47 | ## Gaussian 48 | ### Blue Noise Sequences 49 | ![blue_noise](../../../_2d/samples/blue_noise/Gaussian.png) 50 | ### Irrational Number Sampling 51 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Gaussian.png) 52 | ### Low Discrepancy Sequences 53 | ![lds](../../../_2d/samples/lds/Gaussian.png) 54 | ### Hammersley Low Discrepancy Sequence 55 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Gaussian.png) 56 | ### Regular Sampling 57 | ![regular](../../../_2d/samples/regular/Gaussian.png) 58 | ### Uniform Random Number Sampling 59 | ![uniform_random](../../../_2d/samples/uniform_random/Gaussian.png) 60 | ## Bilinear 61 | ### Blue Noise Sequences 62 | ![blue_noise](../../../_2d/samples/blue_noise/Bilinear.png) 63 | ### Irrational Number Sampling 64 | ![irrational_numbers](../../../_2d/samples/irrational_numbers/Bilinear.png) 65 | ### Low Discrepancy Sequences 66 | ![lds](../../../_2d/samples/lds/Bilinear.png) 67 | ### Hammersley Low Discrepancy Sequence 68 | ![lds_hammersley](../../../_2d/samples/lds_hammersley/Bilinear.png) 69 | ### Regular Sampling 70 | ![regular](../../../_2d/samples/regular/Bilinear.png) 71 | ### Uniform Random Number Sampling 72 | ![uniform_random](../../../_2d/samples/uniform_random/Bilinear.png) 73 | -------------------------------------------------------------------------------- /output/_2d/tests/integration/step.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/tests/integration/step.png -------------------------------------------------------------------------------- /output/_2d/tests/integration/triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/output/_2d/tests/integration/triangle.png -------------------------------------------------------------------------------- /output/_2d/tests/plot/results.md: -------------------------------------------------------------------------------- 1 | # Test Results 2 | tests done: 3 | * MakePlot 4 | ## MakePlot 5 | ### Blue Noise Sequences 6 | #### BestCandidate (Progressive, Randomized) 7 | ![BestCandidate](../../../_2d/samples/blue_noise/MakePlot_BestCandidate.png) 8 | #### BestCandidate5 (Progressive, Randomized) 9 | ![BestCandidate5](../../../_2d/samples/blue_noise/MakePlot_BestCandidate5.png) 10 | #### BestCandidate10 (Progressive, Randomized) 11 | ![BestCandidate10](../../../_2d/samples/blue_noise/MakePlot_BestCandidate10.png) 12 | ### Irrational Number Sampling 13 | #### R2 (Progressive, Deterministic) 14 | ![R2](../../../_2d/samples/irrational_numbers/MakePlot_R2.png) 15 | #### R2Jittered (Progressive, Randomized) 16 | ![R2Jittered](../../../_2d/samples/irrational_numbers/MakePlot_R2Jittered.png) 17 | ### Low Discrepancy Sequences 18 | #### NRooks (Not Progressive, Randomized) 19 | ![NRooks](../../../_2d/samples/lds/MakePlot_NRooks.png) 20 | #### Sobol (Progressive, Deterministic) 21 | ![Sobol](../../../_2d/samples/lds/MakePlot_Sobol.png) 22 | #### Halton_2_3_Zero (Progressive, Deterministic) 23 | ![Halton_2_3_Zero](../../../_2d/samples/lds/MakePlot_Halton_2_3_Zero.png) 24 | #### Halton_2_3 (Progressive, Deterministic) 25 | ![Halton_2_3](../../../_2d/samples/lds/MakePlot_Halton_2_3.png) 26 | #### Halton_5_7 (Progressive, Deterministic) 27 | ![Halton_5_7](../../../_2d/samples/lds/MakePlot_Halton_5_7.png) 28 | #### Halton_13_9 (Progressive, Deterministic) 29 | ![Halton_13_9](../../../_2d/samples/lds/MakePlot_Halton_13_9.png) 30 | ### Hammersley Low Discrepancy Sequence 31 | #### Hammersley2NoOffset (Not Progressive, Deterministic) 32 | ![Hammersley2NoOffset](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2NoOffset.png) 33 | #### Hammersley2 (Not Progressive, Deterministic) 34 | ![Hammersley2](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2.png) 35 | #### Hammersley3 (Not Progressive, Deterministic) 36 | ![Hammersley3](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley3.png) 37 | #### Hammersley5 (Not Progressive, Deterministic) 38 | ![Hammersley5](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley5.png) 39 | #### Hammersley2_1Bit (Not Progressive, Deterministic) 40 | ![Hammersley2_1Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_1Bit.png) 41 | #### Hammersley2_2Bit (Not Progressive, Deterministic) 42 | ![Hammersley2_2Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_2Bit.png) 43 | #### Hammersley2_3Bit (Not Progressive, Deterministic) 44 | ![Hammersley2_3Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_3Bit.png) 45 | #### Hammersley2_4Bit (Not Progressive, Deterministic) 46 | ![Hammersley2_4Bit](../../../_2d/samples/lds_hammersley/MakePlot_Hammersley2_4Bit.png) 47 | ### Regular Sampling 48 | #### Regular (Not Progressive, Deterministic) 49 | ![Regular](../../../_2d/samples/regular/MakePlot_Regular.png) 50 | #### RegularCentered (Not Progressive, Deterministic) 51 | ![RegularCentered](../../../_2d/samples/regular/MakePlot_RegularCentered.png) 52 | #### RegularCenteredOffset (Not Progressive, Deterministic) 53 | ![RegularCenteredOffset](../../../_2d/samples/regular/MakePlot_RegularCenteredOffset.png) 54 | #### RegularJittered (Not Progressive, Randomized) 55 | ![RegularJittered](../../../_2d/samples/regular/MakePlot_RegularJittered.png) 56 | ### Uniform Random Number Sampling 57 | #### UniformRandom (Progressive, Randomized) 58 | ![UniformRandom](../../../_2d/samples/uniform_random/MakePlot_UniformRandom.png) 59 | -------------------------------------------------------------------------------- /premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Atrix256/SampleZoo/3683ce87a83bd653af073a21a05052f7df63d658/premake5.exe -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | dofile("codegen.lua") 2 | dofile("docgen.lua") 3 | print "=====Generating Projects and Solution=====" 4 | 5 | workspace "SampleZoo" 6 | configurations {"Debug", "Release"} 7 | platforms { "Win64", "Win32" } 8 | location "build" 9 | 10 | project "SampleZoo" 11 | kind "ConsoleApp" 12 | language "C++" 13 | targetdir "build/bin/%{cfg.builfcfg}" 14 | 15 | debugdir "./" 16 | 17 | includedirs { "src/", "build/codegen/" } 18 | 19 | files {"src/**.h", "src/**.cpp", "src/**.lua", "src/**.md", "build/codegen/**.h", "build/codegen/**.cpp"} 20 | 21 | filter "files:**.lua" 22 | buildaction "None" 23 | 24 | filter "files:**.md" 25 | buildaction "None" 26 | 27 | filter { "platforms:Win32" } 28 | system "Windows" 29 | architecture "x32" 30 | 31 | filter { "platforms:Win64" } 32 | system "Windows" 33 | architecture "x64" 34 | 35 | filter "configurations:Debug" 36 | defines {"DEBUG"} 37 | symbols "On" 38 | 39 | filter "configurations:Release" 40 | defines {"NDEBUG"} 41 | optimize "on" -------------------------------------------------------------------------------- /src/families/_1d/samples/blue_noise/manual_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: manual_test.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/27/2019 5 | 6 | Description: the hand written manual tests to generate the images specifically needed for documentation. 7 | */ 8 | 9 | #pragma once 10 | 11 | namespace _1d 12 | { 13 | namespace Samples 14 | { 15 | namespace BlueNoise 16 | { 17 | void ManualTest(); 18 | }; 19 | }; 20 | }; -------------------------------------------------------------------------------- /src/families/_1d/samples/blue_noise/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="BlueNoise", 3 | ShortName="Blue Noise", 4 | LongName="Blue Noise Sequences", 5 | Description="Randomized sequences that have only high frequency content", 6 | Functions= { 7 | { name = "BestCandidate", progressive = true, randomized = true, cache = true }, 8 | { name = "BestCandidate5", progressive = true, randomized = true, cache = true }, 9 | { name = "BestCandidate10", progressive = true, randomized = true, cache = true }, 10 | -- commenting out, it isn't useful, doesn't perform well and it isn't that interesting. 11 | -- { name = "BestCandidateRefined", progressive = true, randomized = true, cache = true }, -- it sort of is progressive, sort of not. it's too computationally expensive to treat as non progressive for eg integration :P 12 | }, 13 | } -------------------------------------------------------------------------------- /src/families/_1d/samples/blue_noise/samples.md: -------------------------------------------------------------------------------- 1 | Blue noise samples are randomized but roughly evenly spaced. 2 | 3 | More details: [What is Blue Noise?](../../../../doc/bluenoise.md) 4 | 5 | There are many ways to generate 1d blue noise sample points, but there currently is only one way implemented: 6 | * [Mitchell's Best Candidate](../../../../doc/bestcandidate.md) 7 | 8 | There are three variations, each using a different multiplier for the number of candidates generated compared to how many blue noise samples there already are: 1, 5 and 10. 9 | 10 | # Comparison vs Other Sequences 11 | 12 | ![BestCandidateRefined](../../../_1d/samples/blue_noise/Doc_CalculateDiscrepancy.png) 13 | ![BestCandidateRefined](../../../_1d/samples/blue_noise/Doc_Quadratic.png) 14 | -------------------------------------------------------------------------------- /src/families/_1d/samples/irrational_numbers/irrational_numbers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: irrational_numbers.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | 9 | static const float c_goldenRatioConjugate = 0.61803398875f; 10 | static const float c_pi = 3.14159265359f; 11 | 12 | void _1d::Samples::IrrationalNumbers::GoldenRatioZero(std::vector& values, size_t numValues, std::mt19937& rng) 13 | { 14 | values.resize(numValues); 15 | for (size_t i = 0; i < numValues; ++i) 16 | values[i] = std::fmodf(float(i) * c_goldenRatioConjugate, 1.0f); 17 | } 18 | 19 | void _1d::Samples::IrrationalNumbers::GoldenRatio(std::vector& values, size_t numValues, std::mt19937& rng) 20 | { 21 | values.resize(numValues); 22 | for (size_t i = 0; i < numValues; ++i) 23 | values[i] = std::fmodf(float(i + 1) * c_goldenRatioConjugate, 1.0f); // Don't sample at zero, as first sample! 24 | } 25 | 26 | void _1d::Samples::IrrationalNumbers::Pi(std::vector& values, size_t numValues, std::mt19937& rng) 27 | { 28 | // the part to the left of the decimal point doesn't matter for this, and just makes us hit precision problems sooner. 29 | float piMod1 = std::fmodf(c_pi, 1.0f); 30 | 31 | values.resize(numValues); 32 | for (size_t i = 0; i < numValues; ++i) 33 | values[i] = std::fmodf(float(i + 1) * piMod1, 1.0f); // Don't sample at zero, as first sample! 34 | } 35 | 36 | void _1d::Samples::IrrationalNumbers::Sqrt2(std::vector& values, size_t numValues, std::mt19937& rng) 37 | { 38 | // the part to the left of the decimal point doesn't matter for this, and just makes us hit precision problems sooner. 39 | float sqrt2Mod1 = std::fmodf(std::sqrtf(2.0f), 1.0f); 40 | 41 | values.resize(numValues); 42 | for (size_t i = 0; i < numValues; ++i) 43 | values[i] = std::fmodf(float(i + 1) * sqrt2Mod1, 1.0f); // Don't sample at zero, as first sample! 44 | } 45 | -------------------------------------------------------------------------------- /src/families/_1d/samples/irrational_numbers/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="IrrationalNumbers", 3 | ShortName="Irrational Numbers", 4 | LongName="Irrational Number Sampling", 5 | Description="Multiply an irrational number by the squence index and take that mod 1 to make it be in [0,1)", 6 | Functions= { 7 | { name = "GoldenRatioZero", progressive = true, randomized = false, cache = false }, 8 | { name = "GoldenRatio", progressive = true, randomized = false, cache = false }, 9 | { name = "Pi", progressive = true, randomized = false, cache = false }, 10 | { name = "Sqrt2", progressive = true, randomized = false, cache = false }, 11 | }, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/samples/lds/LDS.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: LDS.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/11/2019 5 | 6 | Description: Low discrepancy sequences 7 | */ 8 | 9 | #include "codegen.h" 10 | 11 | static size_t Ruler(size_t n) 12 | { 13 | size_t ret = 0; 14 | while (n != 0 && (n & 1) == 0) 15 | { 16 | n /= 2; 17 | ++ret; 18 | } 19 | return ret; 20 | } 21 | 22 | static void VanDerCorput(std::vector& values, size_t base) 23 | { 24 | for (size_t i = 0; i < values.size(); ++i) 25 | { 26 | values[i] = 0.0f; 27 | float denominator = float(base); 28 | size_t n = i; 29 | while (n > 0) 30 | { 31 | size_t multiplier = n % base; 32 | values[i] += float(multiplier) / denominator; 33 | n = n / base; 34 | denominator *= base; 35 | } 36 | } 37 | } 38 | 39 | void _1d::Samples::LDS::Sobol(std::vector& values, size_t numValues, std::mt19937& rng) 40 | { 41 | values.resize(numValues); 42 | size_t sampleInt = 0; 43 | for (size_t i = 0; i < numValues; ++i) 44 | { 45 | size_t ruler = Ruler(i + 1); 46 | size_t direction = size_t(size_t(1) << size_t(31 - ruler)); 47 | sampleInt = sampleInt ^ direction; 48 | values[i] = float(sampleInt) / std::pow(2.0f, 32.0f); 49 | } 50 | } 51 | 52 | void _1d::Samples::LDS::VanDerCorput2(std::vector& values, size_t numValues, std::mt19937& rng) 53 | { 54 | values.resize(numValues); 55 | VanDerCorput(values, 2); 56 | } 57 | 58 | void _1d::Samples::LDS::VanDerCorput3(std::vector& values, size_t numValues, std::mt19937& rng) 59 | { 60 | values.resize(numValues); 61 | VanDerCorput(values, 3); 62 | } 63 | 64 | void _1d::Samples::LDS::VanDerCorput5(std::vector& values, size_t numValues, std::mt19937& rng) 65 | { 66 | values.resize(numValues); 67 | VanDerCorput(values, 5); 68 | } 69 | -------------------------------------------------------------------------------- /src/families/_1d/samples/lds/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="LDS", 3 | ShortName="LDS", 4 | LongName="Low Discrepancy Sequences", 5 | Description="Low discrepancy sequences", 6 | Functions= { 7 | { name = "Sobol", progressive = true, randomized = false, cache = false }, 8 | { name = "VanDerCorput2", progressive = true, randomized = false, cache = false }, 9 | { name = "VanDerCorput3", progressive = true, randomized = false, cache = false }, 10 | { name = "VanDerCorput5", progressive = true, randomized = false, cache = false }, 11 | }, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/samples/regular/regular.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: regular.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include 9 | 10 | void _1d::Samples::Regular::Regular(std::vector& values, size_t numValues, std::mt19937& rng) 11 | { 12 | values.resize(numValues); 13 | for (size_t i = 0; i < numValues; ++i) 14 | values[i] = float(i) / float(numValues); 15 | } 16 | 17 | void _1d::Samples::Regular::RegularCentered(std::vector& values, size_t numValues, std::mt19937& rng) 18 | { 19 | values.resize(numValues); 20 | for (size_t i = 0; i < numValues; ++i) 21 | values[i] = float(i) / float(numValues - 1); 22 | } 23 | 24 | void _1d::Samples::Regular::RegularCenteredOffset(std::vector& values, size_t numValues, std::mt19937& rng) 25 | { 26 | float offset = 1.0f / float(numValues * 2); 27 | values.resize(numValues); 28 | for (size_t i = 0; i < numValues; ++i) 29 | values[i] = offset + float(i) / float(numValues); 30 | } 31 | 32 | void _1d::Samples::Regular::RegularJittered(std::vector& values, size_t numValues, std::mt19937& rng) 33 | { 34 | std::uniform_real_distribution dist(0.0f, 1.0f / float(numValues)); 35 | 36 | values.resize(numValues); 37 | for (size_t i = 0; i < numValues; ++i) 38 | values[i] = (float(i) / float(numValues)) + dist(rng); 39 | } 40 | -------------------------------------------------------------------------------- /src/families/_1d/samples/regular/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="Regular", 3 | ShortName="Regular", 4 | LongName="Regular Sampling", 5 | Description="Uniformly spaced samples", 6 | Functions= { 7 | { name = "Regular", progressive = false, randomized = false, cache = false }, 8 | { name = "RegularCentered", progressive = false, randomized = false, cache = false }, 9 | { name = "RegularCenteredOffset", progressive = false, randomized = false, cache = false }, 10 | { name = "RegularJittered", progressive = false, randomized = true, cache = false }, 11 | }, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/samples/uniform_random/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="UniformRandom", 3 | ShortName="Uniform Random", 4 | LongName="Uniform Random Number Sampling", 5 | Description="Randomized sample positions using a uniform random number distribution.", 6 | Functions= { 7 | { name = "UniformRandom", progressive = true, randomized = true, cache = false }, 8 | }, 9 | } -------------------------------------------------------------------------------- /src/families/_1d/samples/uniform_random/samples.md: -------------------------------------------------------------------------------- 1 | Uniform random sampling uses random numbers to make sample positions. 2 | 3 | It's called uniform because it uses a uniform distribution of random numbers. 4 | 5 | This is also known as "white noise" because if you look at the DFT, it has equal probability of having amplitudes in all frequencies. 6 | 7 | This is in contrast to blue noise which only has high frequency content or red noise which only has low frequency content. 8 | 9 | Uniform random sampling doesn't have the aliasing problems that regular sampling does, but instead introduces noise, which is an acceptable trade off. 10 | 11 | A problem with white noise is that the point locations are completely random without regard to any of the other point locations, which means that white noise samples can clump together and leave holes. 12 | 13 | The end result is that uniform random sampling is not very quick at numerical integration, and before it converges it can have a very noticeable and jarring noise pattern. 14 | 15 | Here are some uniform random samples: 16 | 17 | ![UniformRandom](../../../_1d/samples/uniform_random/MakeNumberline_UniformRandom.png) 18 | 19 | Blue noise is an alternative to uniform random sampling which has many of the positive characteristics of white noise, but has a better error rate at lower sample counts, and the noise pattern it leaves is more pleasing to the eye due to being more uniformly distributed. 20 | 21 | ## Links 22 | 23 | http://luc.devroye.org/rnbookindex.html "Non-Uniform Random Variate Generation" - a huge book free online, on all things white noise. 24 | -------------------------------------------------------------------------------- /src/families/_1d/samples/uniform_random/uniform_random.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: uniform_random.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/10/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include 9 | 10 | void _1d::Samples::UniformRandom::UniformRandom(std::vector& values, size_t numValues, std::mt19937& rng) 11 | { 12 | // if they want less samples than there are, just truncate the sequence 13 | if (numValues <= values.size()) 14 | { 15 | values.resize(numValues); 16 | return; 17 | } 18 | 19 | static std::uniform_real_distribution dist(0, 1); 20 | 21 | // generate random samples 22 | for (size_t i = values.size(); i < numValues; ++i) 23 | values.push_back(dist(rng)); 24 | } 25 | -------------------------------------------------------------------------------- /src/families/_1d/tests/dft/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="DFT", 3 | ShortName="DFT", 4 | LongName="Discrete Fourier Transform", 5 | Description="Transforms sampling patterns into frequency space", 6 | Functions= { 7 | "DFT", 8 | }, 9 | MakesIndividualImages = true, 10 | MakesSampleTypeImages = false, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/tests/dft/tests.md: -------------------------------------------------------------------------------- 1 | The discrete Fourier transform transforms a sampling sequence into frequency space. 2 | 3 | The test generates 128 samples and places them as black dots in a 1024x1 white image, and does a DFT of that image. 4 | 5 | For randomized sampling types, it does this test several times and reports the minimum, the maximum, and the average. Deterministic sampling sequences just do a single run. 6 | 7 | There is no difference in this test for progressive vs non progressive sequences since it only ever generates a single 128 length sequence per sequence type. 8 | 9 | No windowing function is used, but in some cases (non torroidal sampling!), a windowing function may make sense. 10 | -------------------------------------------------------------------------------- /src/families/_1d/tests/discrepancy/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Discrepancy", 3 | ShortName="Discrepancy", 4 | LongName="Discrepancy Test", 5 | Description="Calculate metrics about actual point density compared to expected point density if the points were uniformly spaced.", 6 | Functions= { 7 | "CalculateDiscrepancy", 8 | }, 9 | MakesIndividualImages = false, 10 | MakesSampleTypeImages = true, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/tests/discrepancy/tests.md: -------------------------------------------------------------------------------- 1 | Discrepancy is a real number given to a sampling sequence that describes how the points clump together or leave holes. 2 | 3 | Discrepancy is calculated by finding the region with the largest difference between actual density of points and expected density if the points were evenly spaced. The region with the largest difference may be either too dense, or too sparse. That difference between actual and expected density in that region is the discrepancy. 4 | 5 | In higher dimensions, the same process is followed with rectangular regions. Sometimes this process will be simplified to just considering regions where one point is at the origin, which is an approximation of discrepancy calculated more quickly, called "Star Discrepancy", which is written as D*. 6 | 7 | CalculateDiscrepancy() calculates discrepancy assuming that 0 and 1 do not wrap around and are "hard walls". 8 | 9 | The right most empty section that it checks for discrepancy is between the right most point and 1.0. 10 | 11 | For a while, I had a torroidal (wrap around) discrepancy calculation test, to analyze sequences for times when you are sampling something that wraps around, like angles on a circle. It ended up being fairly rare that the "wrap around region" was the region with the largest discrepancy so i removed the test, since the graph looked virtually identical to the non wrap around version. 12 | 13 | ## Links 14 | 15 | How to calculate discrepancy: https://math.stackexchange.com/questions/1681562/how-to-calculate-discrepancy-of-a-sequence 16 | 17 | Wikipedia links: 18 | * https://en.wikipedia.org/wiki/Equidistributed_sequence#Discrepancy 19 | * https://en.wikipedia.org/wiki/Low-discrepancy_sequence#Definition_of_discrepancy 20 | 21 | Star Discrepancy from Wolfram Math World: http://mathworld.wolfram.com/StarDiscrepancy.html 22 | 23 | ## Papers 24 | 25 | "Discrepancy as a Quality Measure for Sample Distributions" by Peter Shirley (1991) 26 | http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.40.7922&rep=rep1&type=pdf 27 | 28 | 29 | "Random-Edge Discrepancy of Supersampling Patterns" by David Dobkin & Don Mitchel (1993) 30 | https://pdfs.semanticscholar.org/5aec/55d3f5ed875a694cc3fb6a0cee42bd8cb92d.pdf 31 | 32 | 33 | "Analysis of Forced Random Sampling" by Daniel Cornel 34 | http://drivenbynostalgia.com/files/DA.pdf 35 | -------------------------------------------------------------------------------- /src/families/_1d/tests/integration/manual_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: manual_test.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/9/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | namespace _1d 10 | { 11 | namespace Tests 12 | { 13 | namespace Integration 14 | { 15 | void ManualTest(); 16 | }; 17 | }; 18 | }; -------------------------------------------------------------------------------- /src/families/_1d/tests/integration/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Integration", 3 | ShortName="Integration", 4 | LongName="Numerical Integration", 5 | Description="Use sample points to integrate 1d functions", 6 | Functions= { 7 | "Linear", 8 | "Step", 9 | "Exp", 10 | "Quadratic" 11 | }, 12 | MakesIndividualImages = false, 13 | MakesSampleTypeImages = true, 14 | SamplePageShowsFunctionName = true, 15 | } -------------------------------------------------------------------------------- /src/families/_1d/tests/integration/tests.md: -------------------------------------------------------------------------------- 1 | Numerical integration is what this site is all about really, so this test is pretty important. 2 | 3 | If you have a function y=f(x) and you want to know what the area of the graph is from 0 to W, one way to do it is to take N samples of the function (plug N different values of x in to get N values of y out), where the samples are between 0 and W, and then average them. 4 | 5 | This average gives you an "average height" of the graph from 0 to W, so to get the area under the graph, you can now treat it like a rectangle where that value is the height, and W is the width. Multiply them together and you have an estimate for the area under the graph. 6 | 7 | A common way to sample is to use random numbers (white noise). When you do this, it's called monte carlo integration. 8 | 9 | You can use other sampling types though as well, such as low discrepancy sequences, and can still provably have your estimate head towards the right answer, and provably do so faster than white noise (more accuracy for the same number of samples). 10 | 11 | When the error is low enough, you can say that it has converged. 12 | 13 | This test uses each sampling type to try and integrate the following functions from 0 to 1: 14 | * Linear: y = x 15 | * Step: y = (x > 0.5) ? 1.0 : 0.0 16 | * Exp: y = e^x 17 | * Quadratic: y=-3x^2+2x+1 18 | 19 | ![Linear](linear.png) 20 | ![Step](step.png) 21 | ![Exp](exp.png) 22 | ![Quadratic](quadratic.png) 23 | 24 | ## links 25 | 26 | https://blog.demofox.org/2018/06/12/monte-carlo-integration-explanation-in-1d/ - Monte Carlo Integration Explanation in 1D. 27 | -------------------------------------------------------------------------------- /src/families/_1d/tests/numberline/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Numberline", 3 | ShortName="Numberline", 4 | LongName="Numberline", 5 | Description="Makes numberlines", 6 | Functions= { 7 | "MakeNumberline", 8 | }, 9 | MakesIndividualImages = true, 10 | MakesSampleTypeImages = false, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_1d/tests/numberline/tests.md: -------------------------------------------------------------------------------- 1 | The MakeNumberline() function makes a numberline image from the samples you give it, and writes it to disk as a png, with the specified filename. 2 | 3 | The first sample is red and the last sample is green. This lets you see the order of the samples on the numberline. -------------------------------------------------------------------------------- /src/families/_2d/samples/blue_noise/blue_noise.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: blue_noise.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/3/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include 9 | #include 10 | 11 | static void BestCandidateN(std::vector& values, size_t numValues, std::mt19937& rng, const size_t c_blueNoiseSampleMultiplier) 12 | { 13 | // if they want less samples than there are, just truncate the sequence 14 | if (numValues <= values.size()) 15 | { 16 | values.resize(numValues); 17 | return; 18 | } 19 | 20 | static std::uniform_real_distribution dist(0, 1); 21 | 22 | for (size_t i = values.size(); i <= numValues; ++i) 23 | { 24 | // keep the candidate that is farthest from it's closest point 25 | size_t numCandidates = values.size() * c_blueNoiseSampleMultiplier + 1; 26 | float bestDistance = 0.0f; 27 | Vec2 bestCandidatePos = Vec2{ 0.0f, 0.0f }; 28 | for (size_t candidate = 0; candidate < numCandidates; ++candidate) 29 | { 30 | Vec2 candidatePos = Vec2{ dist(rng), dist(rng) }; 31 | 32 | // calculate the closest distance from this point to an existing sample 33 | float minDist = FLT_MAX; 34 | for (const Vec2& samplePos : values) 35 | { 36 | float dist = DistanceUnitTorroidal(samplePos, candidatePos); 37 | if (dist < minDist) 38 | minDist = dist; 39 | } 40 | 41 | if (minDist > bestDistance) 42 | { 43 | bestDistance = minDist; 44 | bestCandidatePos = candidatePos; 45 | } 46 | } 47 | values.push_back(bestCandidatePos); 48 | } 49 | } 50 | 51 | void _2d::Samples::BlueNoise::BestCandidate(std::vector& values, size_t numValues, std::mt19937& rng) 52 | { 53 | BestCandidateN(values, numValues, rng, 1); 54 | } 55 | 56 | void _2d::Samples::BlueNoise::BestCandidate5(std::vector& values, size_t numValues, std::mt19937& rng) 57 | { 58 | BestCandidateN(values, numValues, rng, 5); 59 | } 60 | 61 | void _2d::Samples::BlueNoise::BestCandidate10(std::vector& values, size_t numValues, std::mt19937& rng) 62 | { 63 | BestCandidateN(values, numValues, rng, 10); 64 | } 65 | -------------------------------------------------------------------------------- /src/families/_2d/samples/blue_noise/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="BlueNoise", 3 | ShortName="Blue Noise", 4 | LongName="Blue Noise Sequences", 5 | Description="Randomized sequences that have only high frequency content", 6 | Functions= { 7 | { name = "BestCandidate", progressive = true, randomized = true, cache = true }, 8 | { name = "BestCandidate5", progressive = true, randomized = true, cache = true }, 9 | { name = "BestCandidate10", progressive = true, randomized = true, cache = true }, 10 | }, 11 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/blue_noise/samples.md: -------------------------------------------------------------------------------- 1 | Blue noise samples are randomized but roughly evenly spaced. 2 | 3 | More details: [What is Blue Noise?](../../../../doc/bluenoise.md) 4 | 5 | There are many ways to generate 2d blue noise sample points, but there currently is only one way implemented: 6 | * [Mitchell's Best Candidate](../../../../doc/bestcandidate.md) 7 | 8 | There are three variations, each using a different multiplier for the number of candidates generated compared to how many blue noise samples there already are: 1, 5 and 10. -------------------------------------------------------------------------------- /src/families/_2d/samples/irrational_numbers/irrational_numbers.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: irrational_numbers.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/4/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | 9 | static const float c_goldenRatioConjugate = 0.61803398875f; 10 | static const float c_pi = 3.14159265359f; 11 | 12 | void _2d::Samples::IrrationalNumbers::R2(std::vector& values, size_t numValues, std::mt19937& rng) 13 | { 14 | // Generalized golden ratio to 2d. 15 | // Solution to x^3 = x + 1 16 | // AKA plastic constant. 17 | // from http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ 18 | float g = 1.32471795724474602596f; 19 | float a1 = 1.0f / g; 20 | float a2 = 1.0f / (g*g); 21 | 22 | values.resize(numValues); 23 | for (int i = 0; i < numValues; ++i) 24 | { 25 | values[i][0] = fmodf(0.5f + a1 * float(i), 1.0f); 26 | values[i][1] = fmodf(0.5f + a2 * float(i), 1.0f); 27 | } 28 | } 29 | 30 | void _2d::Samples::IrrationalNumbers::R2Jittered(std::vector& values, size_t numValues, std::mt19937& rng) 31 | { 32 | // A jitter is added to R2 to give it blue noise like properties. 33 | // from http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/ 34 | float g = 1.32471795724474602596f; 35 | float a1 = 1.0f / g; 36 | float a2 = 1.0f / (g*g); 37 | 38 | std::uniform_real_distribution dist(0.0f, 1.0f); 39 | 40 | static const float c_magicNumber = 0.732f; 41 | 42 | values.resize(numValues); 43 | for (int i = 0; i < numValues; ++i) 44 | { 45 | values[i][0] = fmodf(dist(rng) * c_magicNumber / sqrtf(float(i + 1)) + a1 * float(i), 1.0f); 46 | values[i][1] = fmodf(dist(rng) * c_magicNumber / sqrtf(float(i + 1)) + a2 * float(i), 1.0f); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/families/_2d/samples/irrational_numbers/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="IrrationalNumbers", 3 | ShortName="Irrational Numbers", 4 | LongName="Irrational Number Sampling", 5 | Description="Using irrational numbers to make 2d low discrepancy sequences", 6 | Functions= { 7 | { name = "R2", progressive = true, randomized = false, cache = false }, 8 | { name = "R2Jittered", progressive = true, randomized = true, cache = false }, 9 | }, 10 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/irrational_numbers/samples.md: -------------------------------------------------------------------------------- 1 | This extends the concept of irrational numbers from 1d to 2d. 2 | 3 | Check out the 1d irrational number sequence page for an explanation of the basic idea: 4 | [1D Irrational Number Sequences](../../../2d/output/_1d/samples/irrational_numbers/page.md) 5 | 6 | There are currently two 2d irrational number sequence implementations: 7 | * R2 8 | * R2 Jittered 9 | 10 | ## R2 11 | 12 | This sequence was discovered and written about by Martin Roberts (https://twitter.com/TechSparx) at http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ 13 | 14 | R2 works by generalizing the golden ratio. 15 | 16 | Normally where the golden ratio is the positive solution to the equation x^2=x+1, R2 is based on the real (non imaginary) solution to the equation x^3=x+1. 17 | 18 | This number is also called "the plastic constant" and is approximately 1.32471795724474602596. 19 | 20 | Let's call that number "g". 21 | 22 | To calculate N 2d sampling points, you loop from 0 to N-1 and calculate it like this: 23 | * x = (index / g) % 1 24 | * y = (index / (g * g)) % 1 25 | 26 | When indexing starting at zero, the first sample will be (0,0) which we've seen hasn't worked out very well for other sequences, so you can add (0.5, 0.5) to this to make it start in the center and have better properties. 27 | 28 | That means you modify the calculations to be this: 29 | * x = (0.5 + index / g) % 1 30 | * y = (0.5 + index / (g * g)) % 1 31 | 32 | ## R2 Jittered 33 | 34 | Knowing that jittering sampling locations can give sampling sequences more blue noise type properties (such as less aliasing), Martin added some jittering to his R2 sequence with good success. He wrote up the details at http://extremelearning.com.au/a-simple-method-to-construct-isotropic-quasirandom-blue-noise-point-sequences/. 35 | 36 | ## Links 37 | 38 | https://en.wikipedia.org/wiki/Plastic_number - The Plastic Constant -------------------------------------------------------------------------------- /src/families/_2d/samples/lds/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="LDS", 3 | ShortName="LDS", 4 | LongName="Low Discrepancy Sequences", 5 | Description="Low discrepancy sequences", 6 | Functions= { 7 | { name = "NRooks", progressive = false, randomized = true, cache = false }, 8 | 9 | { name = "Sobol", progressive = true, randomized = false, cache = false }, 10 | 11 | { name = "Halton_2_3_Zero", progressive = true, randomized = false, cache = false }, 12 | { name = "Halton_2_3", progressive = true, randomized = false, cache = false }, 13 | { name = "Halton_5_7", progressive = true, randomized = false, cache = false }, 14 | { name = "Halton_13_9", progressive = true, randomized = false, cache = false }, 15 | }, 16 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/lds/samples.md: -------------------------------------------------------------------------------- 1 | This extends the concept of low discrepancy numbers from 1d to 2d. 2 | 3 | Check out the 1d low discrepancy sequence page for an explanation of the basic ideas: 4 | [1D Low Discrepancy Sequences](../../../2d/output/_1d/samples/lds/page.md) 5 | 6 | ## N-Rooks 7 | 8 | N-Rooks is a sampling pattern where you treat an NxN image as if it were a chess board. Every sampling position is a rook that could move horizontally or vertically, and should be placed such that none of these rooks could capture / "see" any of the other rooks. 9 | 10 | In other words, every column has a single sample point in it, and every row has a single sample point in it. 11 | 12 | An easy way to do this is to start by having a diagonal line of the rooks like (0,0) (1,1) (2,2) ... (N-1, N1), and then randomly shuffling the rows. 13 | 14 | While this sampling pattern is randomized pretty heavily using white noise, the 1d projections of this pattern on the X and Y axis have no overlap and are a shuffle, making it better than white noise and also pretty easy to generate. 15 | 16 | 17 | 18 | 19 | TODO: finish this page! -------------------------------------------------------------------------------- /src/families/_2d/samples/lds_hammersley/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="LDSHammersley", 3 | ShortName="Hammersley (LDS)", 4 | LongName="Hammersley Low Discrepancy Sequence", 5 | Description="Low discrepancy sequences", 6 | Functions= { 7 | { name = "Hammersley2NoOffset", progressive = false, randomized = false, cache = false }, 8 | { name = "Hammersley2", progressive = false, randomized = false, cache = false }, 9 | { name = "Hammersley3", progressive = false, randomized = false, cache = false }, 10 | { name = "Hammersley5", progressive = false, randomized = false, cache = false }, 11 | 12 | { name = "Hammersley2_1Bit", progressive = false, randomized = false, cache = false }, 13 | { name = "Hammersley2_2Bit", progressive = false, randomized = false, cache = false }, 14 | { name = "Hammersley2_3Bit", progressive = false, randomized = false, cache = false }, 15 | { name = "Hammersley2_4Bit", progressive = false, randomized = false, cache = false }, 16 | }, 17 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/lds_hammersley/samples.md: -------------------------------------------------------------------------------- 1 | This extends the concept of low discrepancy numbers from 1d to 2d. 2 | 3 | Check out the 1d low discrepancy sequence page for an explanation of the basic ideas: 4 | [1D Low Discrepancy Sequences](../../../2d/output/_1d/samples/lds/page.md) 5 | 6 | ## Hammersley Sequence 7 | 8 | The Hammersley sequence in 2D is just the 1d Van Der Corput sequence on one axis, and regular sampling on the other axis. 9 | 10 | In higher dimensions, you do Van Der Corput on each axis except one, and do regular sampling on that last axis. Another way of saying that is that it's Halton on all except the last axis, and regular on the last axis. Those two ways of explaining it are exactly the same. 11 | 12 | Not all choices for base for the VDC axis are good though as you'll see in the test results. 2 and 3 are decent, but 5 is very obviously not a great choice. 13 | 14 | Wikipedia describes it exactly like I have (https://en.wikipedia.org/wiki/Low-discrepancy_sequence#Hammersley_set) while wolfram math world describes it differently (http://mathworld.wolfram.com/HammersleyPointSet.html). 15 | 16 | Wolfram math world says that the last axis isn't index / N, but instead, you reverse the bits and treat them like fractions. It turns out that these are actually exactly equivalent (same values, same order) so long as you are using base 2, and that you have a power of 2 number of samples. (more generaly, when using base N and a power of N number of samples, you reverse the N-its and treat them like fractions) 17 | 18 | ### The Usual Regular Sampling Situation 19 | 20 | Hammersley is Van Der Corput sequences on all axes except one (which you could also say it's Halton on all axes except one, which means the same thing), but that one axis is just regular sampling. 21 | 22 | All the common descriptions of Hammersley I could find left it at that, but if you think back to the 1d regular sampling, you'll remember that index/N is not really great for regular sampling. 23 | 24 | If you need a refresher on that: [1D Regular Sampling](../../../2d/output/_1d/samples/regular/page.md) 25 | 26 | At this point in time, I don't see much of a difference 27 | 28 | TODO: finish this section. Maybe do manual test to compare offset vs not 29 | 30 | ### Truncating Bits 31 | 32 | Beyond the above, you can also modify Hammersley sequences by "truncating bits" (bits in base 2, trits in base 3, etc) from the least significant side of the numbers. 33 | 34 | As an example of this, doing 64 samples of base 2 hammersley (6 bits), the first couple samples would be... 35 | 36 | x0 = 000000 = 0 37 | y0 = 000000 = 0 38 | 39 | x1 = 000001 = 1/2 40 | y1 = 100000 = 1/64 41 | 42 | x2 = 000010 = 1/4 43 | y2 = 010000 = 1/32 44 | 45 | x3 = 000011 = 3/4 46 | y3 = 110000 = 3/64 47 | 48 | x4 = 000100 = 1/8 49 | y4 = 001000 = 1/16 50 | 51 | ... 52 | 53 | If you were to truncate 1 bit from each axis you'd get this: 54 | 55 | x0 = 00000 = 0 56 | y0 = 00000 = 0 57 | 58 | x1 = 00001 = 1/2 59 | y1 = 00000 = 0 60 | 61 | x2 = 00010 = 1/4 62 | y2 = 10000 = 1/32 63 | 64 | x3 = 00011 = 3/4 65 | y3 = 10000 = 1/32 66 | 67 | x4 = 00100 = 1/8 68 | y4 = 01000 = 1/16 69 | 70 | ... 71 | 72 | Truncating 2 bits would give you this: 73 | 74 | x0 = 0000 = 0 75 | y0 = 0000 = 0 76 | 77 | x1 = 0001 = 1/2 78 | y1 = 0000 = 0 79 | 80 | x2 = 0010 = 1/4 81 | y2 = 0000 = 0 82 | 83 | x3 = 0011 = 3/4 84 | y3 = 0000 = 0 85 | 86 | x4 = 0100 = 1/8 87 | y4 = 1000 = 1/16 88 | 89 | ... 90 | 91 | And truncating 3 bits would give you this, which since it leaves 3 unique bits per each axis ends up becoming a regular grid of 8x8 samples. 92 | 93 | x0 = 000 = 0 94 | y0 = 000 = 0 95 | 96 | x1 = 001 = 1/2 97 | y1 = 000 = 0 98 | 99 | x2 = 010 = 1/4 100 | y2 = 000 = 0 101 | 102 | x3 = 011 = 3/4 103 | y3 = 000 = 0 104 | 105 | x4 = 100 = 1/8 106 | y4 = 000 = 0 107 | 108 | ... 109 | 110 | Going beyond 3 bits gives a regular grid as well, but with fewer unique points. Truncating 4 bits gives you a 4x4 grid. Truncating 5 bits gives you a 2x2 grid. Truncating 6 bits gives you a single point where all the samples lie, at (0,0). 111 | 112 | From my testing, truncating bits in 2d makes for a worse sequence, but maybe it works better in higher dimensions. 113 | -------------------------------------------------------------------------------- /src/families/_2d/samples/regular/regular.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: regular.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/4/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include 9 | 10 | void _2d::Samples::Regular::Regular(std::vector& values, size_t numValues, std::mt19937& rng) 11 | { 12 | size_t sizeX = size_t(sqrtf(float(numValues))); 13 | size_t sizeY = numValues / sizeX; 14 | 15 | values.resize(numValues, Vec2{ 0.0f, 0.0f }); 16 | int i = 0; 17 | for (size_t iy = 0; iy < sizeY; ++iy) 18 | { 19 | for (size_t ix = 0; ix < sizeX; ++ix) 20 | { 21 | values[i][0] = float(ix) / float(sizeX); 22 | values[i][1] = float(iy) / float(sizeY); 23 | ++i; 24 | } 25 | } 26 | } 27 | 28 | void _2d::Samples::Regular::RegularCentered(std::vector& values, size_t numValues, std::mt19937& rng) 29 | { 30 | size_t sizeX = size_t(sqrtf(float(numValues))); 31 | size_t sizeY = numValues / sizeX; 32 | 33 | values.resize(numValues, Vec2{ 0.0f, 0.0f }); 34 | int i = 0; 35 | for (size_t iy = 0; iy < sizeY; ++iy) 36 | { 37 | for (size_t ix = 0; ix < sizeX; ++ix) 38 | { 39 | values[i][0] = float(ix) / float(sizeX - 1); 40 | values[i][1] = float(iy) / float(sizeY - 1); 41 | ++i; 42 | } 43 | } 44 | } 45 | 46 | void _2d::Samples::Regular::RegularCenteredOffset(std::vector& values, size_t numValues, std::mt19937& rng) 47 | { 48 | size_t sizeX = size_t(sqrtf(float(numValues))); 49 | size_t sizeY = numValues / sizeX; 50 | 51 | float offsetX = 1.0f / float(sizeX * 2); 52 | float offsetY = 1.0f / float(sizeY * 2); 53 | 54 | values.resize(numValues, Vec2{ 0.0f, 0.0f }); 55 | int i = 0; 56 | for (size_t iy = 0; iy < sizeY; ++iy) 57 | { 58 | for (size_t ix = 0; ix < sizeX; ++ix) 59 | { 60 | values[i][0] = offsetX + float(ix) / float(sizeX); 61 | values[i][1] = offsetY + float(iy) / float(sizeY); 62 | ++i; 63 | } 64 | } 65 | } 66 | 67 | void _2d::Samples::Regular::RegularJittered(std::vector& values, size_t numValues, std::mt19937& rng) 68 | { 69 | size_t sizeX = size_t(sqrtf(float(numValues))); 70 | size_t sizeY = numValues / sizeX; 71 | 72 | std::uniform_real_distribution distX(0.0f, 1.0f / float(sizeX)); 73 | std::uniform_real_distribution distY(0.0f, 1.0f / float(sizeY)); 74 | 75 | values.resize(numValues, Vec2{ 0.0f, 0.0f }); 76 | int i = 0; 77 | for (size_t iy = 0; iy < sizeY; ++iy) 78 | { 79 | for (size_t ix = 0; ix < sizeX; ++ix) 80 | { 81 | values[i][0] = distX(rng) + float(ix) / float(sizeX); 82 | values[i][1] = distY(rng) + float(iy) / float(sizeY); 83 | ++i; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/families/_2d/samples/regular/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="Regular", 3 | ShortName="Regular", 4 | LongName="Regular Sampling", 5 | Description="Uniformly spaced samples", 6 | Functions= { 7 | { name = "Regular", progressive = false, randomized = false, cache = false }, 8 | { name = "RegularCentered", progressive = false, randomized = false, cache = false }, 9 | { name = "RegularCenteredOffset", progressive = false, randomized = false, cache = false }, 10 | { name = "RegularJittered", progressive = false, randomized = true, cache = false }, 11 | }, 12 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/regular/samples.md: -------------------------------------------------------------------------------- 1 | The 2d regular sampling sequences are direct extensions of the 1d regular sampling sequences. 2 | 3 | [1D Regular Sampling](../../../_1d/samples/regular/page.md) 4 | 5 | It might be odd to see that RegularJittered has the lowest discrepancy of these sequences, but discrepancy gets a bit more complex in 2d. Basically, those big empty rows and columns between samples in regular sampling contribute to making larger discrepancy for those sequences. Adding random jitter causes those regions to get broken up. 6 | 7 | The lower discrepancy means that it also does better at integration. 8 | -------------------------------------------------------------------------------- /src/families/_2d/samples/uniform_random/samples.lua: -------------------------------------------------------------------------------- 1 | sampleInfo = { 2 | CodeName="UniformRandom", 3 | ShortName="Uniform Random", 4 | LongName="Uniform Random Number Sampling", 5 | Description="Randomized sample positions using a uniform random number distribution.", 6 | Functions= { 7 | { name = "UniformRandom", progressive = true, randomized = true, cache = false }, 8 | }, 9 | } -------------------------------------------------------------------------------- /src/families/_2d/samples/uniform_random/samples.md: -------------------------------------------------------------------------------- 1 | Uniform random sampling in 2d is exactly the same as uniform random sampling in 1d with very similar properties. 2 | 3 | [1D Regular Sampling](../../../_1d/samples/uniform_random/page.md) -------------------------------------------------------------------------------- /src/families/_2d/samples/uniform_random/uniform_random.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: uniform_random.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/3/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include 9 | 10 | void _2d::Samples::UniformRandom::UniformRandom(std::vector& values, size_t numValues, std::mt19937& rng) 11 | { 12 | // if they want less samples than there are, just truncate the sequence 13 | if (numValues <= values.size()) 14 | { 15 | values.resize(numValues); 16 | return; 17 | } 18 | 19 | static std::uniform_real_distribution dist(0, 1); 20 | 21 | // generate random samples 22 | for (size_t i = values.size(); i < numValues; ++i) 23 | values.push_back(Vec2{ dist(rng), dist(rng) }); 24 | } 25 | -------------------------------------------------------------------------------- /src/families/_2d/tests/dft/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="DFT", 3 | ShortName="DFT", 4 | LongName="Discrete Fourier Transform", 5 | Description="Transforms sampling patterns into frequency space", 6 | Functions= { 7 | "DFT", 8 | }, 9 | MakesIndividualImages = true, 10 | MakesSampleTypeImages = false, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_2d/tests/dft/tests.md: -------------------------------------------------------------------------------- 1 | This is the same as the 1d DFT test, but in 2d. The center of the image is 0hz. 2 | 3 | [1D DFT Test](../../../_1d/tests/dft/page.md) 4 | 5 | Nothing special is done for randomized vs deterministic sequences, or progressive vs non progressive sequences. -------------------------------------------------------------------------------- /src/families/_2d/tests/discrepancy/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Discrepancy", 3 | ShortName="Discrepancy", 4 | LongName="Discrepancy Test", 5 | Description="Calculate metrics about actual point density compared to expected point density if the points were uniformly spaced.", 6 | Functions= { 7 | "CalculateDiscrepancy", 8 | }, 9 | MakesIndividualImages = false, 10 | MakesSampleTypeImages = true, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_2d/tests/discrepancy/tests.md: -------------------------------------------------------------------------------- 1 | This is the same as the 1d discrepancy test, but in 2d. 2 | 3 | [1D Discrepancy Test](../../../_1d/tests/discrepancy/page.md) 4 | 5 | Calculating discrepancy gets a lot more expensive each dimension you go up. 6 | 7 | In 1d, it's an O(n^2) operation, but in 2d, it's an O(n^4) operation. This is because in 1d, you have to consider every pair of points (n^2), but in higher dimensions you have to do the same, but on each axis individually. 8 | 9 | Intuition about discrepancy changes as you go up in dimension as well. What had low discrepancy in 1d may not have low discrepancy in 2d and higher. For instance, in 1d, regular sampling had the lowest discrepancy, but in 2d (and up), that isn't the case due to those long rows and columns of empty space between the sampling points. 10 | 11 | Blue noise has lower discrepancy than regular sampling in 2d, as does regular jittered sampling. Neither of those things are true in 1d. 12 | 13 | This difference in discrepancy also affects how well the sequences perform for integration. 14 | -------------------------------------------------------------------------------- /src/families/_2d/tests/integration/manual_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: manual_test.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/9/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | namespace _2d 10 | { 11 | namespace Tests 12 | { 13 | namespace Integration 14 | { 15 | void ManualTest(); 16 | }; 17 | }; 18 | }; -------------------------------------------------------------------------------- /src/families/_2d/tests/integration/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Integration", 3 | ShortName="Integration", 4 | LongName="Numerical Integration", 5 | Description="Use sample points to integrate 2d functions", 6 | Functions= { 7 | "Disk", 8 | "Triangle", 9 | "Step", 10 | "Gaussian", 11 | "Bilinear" 12 | }, 13 | MakesIndividualImages = false, 14 | MakesSampleTypeImages = true, 15 | SamplePageShowsFunctionName = true, 16 | } -------------------------------------------------------------------------------- /src/families/_2d/tests/integration/tests.md: -------------------------------------------------------------------------------- 1 | This is the same as the 1d integration test, but integrating over 2d functions instead of 1d functions. 2 | 3 | [1D Integration Test](../../../_1d/tests/integration/page.md) 4 | 5 | The functions being integrated over are: 6 | * Disk: the inside of a circle with radius 2/pi 7 | * Triangle: y > x 8 | * Step: x < 1/pi 9 | * Gaussian: z = e^(-x^2-y^2) 10 | * Bilinear: z = x * y 11 | 12 | ![Disk](disk.png) 13 | ![Triangle](triangle.png) 14 | ![Step](step.png) 15 | ![Gaussian](gaussian.png) 16 | ![Bilinear](bilinear.png) 17 | -------------------------------------------------------------------------------- /src/families/_2d/tests/plot/plot.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: plot.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 3/3/2019 5 | */ 6 | 7 | #include "codegen.h" 8 | #include "stb/stb_image_write.h" 9 | #include "shared/pixel.h" 10 | #include "shared/drawing.h" 11 | #include "shared/image.h" 12 | #include "shared/color_spaces.h" 13 | #include "shared/math.h" 14 | #include "shared/drawtext.h" 15 | 16 | static Image MakePlot(const std::vector& samples, int width) 17 | { 18 | const int height = width; 19 | 20 | Image image(width, height, { 1.0f, 1.0f, 1.0f, 1.0f}); 21 | 22 | float paddingMinX = 0.1f; 23 | float paddingMaxX = 0.9f; 24 | float paddingMinY = 0.1f; 25 | float paddingMaxY = 0.9f; 26 | 27 | DrawBox(image, Vec2{ paddingMinX, paddingMinY }, Vec2{ paddingMaxX, paddingMaxY }, { 0.85f, 0.85f, 0.85f, 1.0f }); 28 | 29 | for (size_t i = 0; i < samples.size(); ++i) 30 | { 31 | static const PixelRGBAF32 srcColor(1.0f, 0.0f, 0.0f, 1.0f); 32 | static const PixelRGBAF32 destColor(0.0f, 1.0f, 0.0f, 1.0f); 33 | 34 | float t = float(i) / float(samples.size() - 1); 35 | PixelRGBAF32 color; 36 | color.r = Lerp(srcColor.r, destColor.r, t); 37 | color.g = Lerp(srcColor.g, destColor.g, t); 38 | color.b = Lerp(srcColor.b, destColor.b, t); 39 | color.a = Lerp(srcColor.a, destColor.a, t); 40 | 41 | // normalize the interpolated color to make the middle yellow part brighter 42 | float len = sqrtf(color.r*color.r + color.g*color.g + color.b*color.b); 43 | color.r /= len; 44 | color.g /= len; 45 | color.b /= len; 46 | 47 | Vec2 paddingMin = { paddingMinX, paddingMinY }; 48 | Vec2 paddingMax = { paddingMaxX, paddingMaxY }; 49 | 50 | // draw the 2d sample location 51 | Vec2 samplePos = samples[i] * (paddingMax - paddingMin) + paddingMin; 52 | DrawCircle(image, samplePos, 5.0f / 512.0f, color); 53 | 54 | // draw the x axis projection 55 | DrawCircle(image, Vec2{ 0.05f, samplePos[1] }, 5.0f / 512.0f, color); 56 | 57 | // draw the y axis projection 58 | DrawCircle(image, Vec2{ samplePos[0], 0.95f }, 5.0f / 512.0f, color); 59 | } 60 | 61 | // draw borders 62 | DrawLine(image, paddingMinX, paddingMinY, paddingMinX, paddingMaxY, { 0.125f, 0.125f, 0.125f, 1.0f }, 2.0f / 512.0f); 63 | DrawLine(image, paddingMaxX, paddingMinY, paddingMaxX, paddingMaxY, { 0.125f, 0.125f, 0.125f, 1.0f }, 2.0f / 512.0f); 64 | DrawLine(image, paddingMinX, paddingMinY, paddingMaxX, paddingMinY, { 0.125f, 0.125f, 0.125f, 1.0f }, 2.0f / 512.0f); 65 | DrawLine(image, paddingMinX, paddingMaxY, paddingMaxX, paddingMaxY, { 0.125f, 0.125f, 0.125f, 1.0f }, 2.0f / 512.0f); 66 | 67 | return image; 68 | } 69 | 70 | void _2d::Tests::Plot::MakePlot(const std::vector>& sampleFunctions, const char* testName, const char* fileNamePrefix) 71 | { 72 | char fileName[256]; 73 | std::vector sampleCounts = { 8, 16, 32, 64 }; 74 | 75 | for (const std::vector& sampleType : sampleFunctions) 76 | { 77 | for (const SampleGenerateInfo_2d& sampleFunction : sampleType) 78 | { 79 | Image result; 80 | 81 | std::vector samples; 82 | for (size_t sampleCountIndex = 0; sampleCountIndex < sampleCounts.size(); ++sampleCountIndex) 83 | { 84 | sampleFunction.function(samples, sampleCounts[sampleCountIndex], sampleFunction.cacheKey, false); 85 | Image newImage = ::MakePlot(samples, 256); 86 | 87 | char buffer[256]; 88 | sprintf(buffer, "%zu samples", sampleCounts[sampleCountIndex]); 89 | DrawText(newImage, buffer, { 0.0f, 0.0f, 0.0f, 1.0f }, 40.0f / 512.0f, Vec2{ 0.5f, 0.0f }, TextHAlign::Center, TextVAlign::Top); 90 | 91 | BlendInImage_Resize(result, newImage, result.m_width, 0, { 0.0f, 0.0f, 0.0f, 1.0f }); 92 | } 93 | 94 | sprintf(fileName, "output/%s/samples/%s/%s_%s.png", sampleFunction.sampleFamily, sampleFunction.sampleType, testName, sampleFunction.name); 95 | SaveImage(result, fileName); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/families/_2d/tests/plot/tests.lua: -------------------------------------------------------------------------------- 1 | testInfo = { 2 | CodeName="Plot", 3 | ShortName="Plot", 4 | LongName="Plot", 5 | Description="Plots sequences", 6 | Functions= { 7 | "MakePlot", 8 | }, 9 | MakesIndividualImages = true, 10 | MakesSampleTypeImages = false, 11 | SamplePageShowsFunctionName = false, 12 | } -------------------------------------------------------------------------------- /src/families/_2d/tests/plot/tests.md: -------------------------------------------------------------------------------- 1 | Plotting 2d sample points is the 2d equivelant of the 1d numberline tests. 2 | 3 | [1D Regular Sampling](../../../_1d/tests/numberline/page.md) 4 | 5 | A difference from 1d however, is that we also project the points to the X and Y axis. 6 | 7 | Several modern research papers say and show that sampling sequences that are "still good" (for instance, low discrepancy) when projected to an axis outperform sequences that don't. This test showing those projections let you see how well the sequences project to those lower subspaces. 8 | 9 | For some intuition about why this is true, imagine that you are integrating over a square region of pixels that has a vertical line in it, where everything to the right is black, and everything to the left is white. 10 | 11 | When you use a 2d sampling location to sample this region, the y axis doesn't matter. Whatever you change the y axis to, as long as you leave x alone, you'll get the same value. 12 | 13 | Because of this, it reduces the sampling / integration problem to 1d, on the x axis specifically. 14 | 15 | That means that the quality of the sampling sequence in this situation is going to be based entirely on how good the x axis projection of the sampling sequence can do in 1d. 16 | 17 | This might sound far fetched, but imagine trying to integrate some soft shadows for a vertical building. You are likely going to hit this exact problem. 18 | 19 | Thinking about this, you might wonder (like i do) why the x and y axis is so special. Wouldn't you want something that projects as well as possible on all random axes? I definitely think so but have not yet seen any research papers talking about this. 20 | 21 | ## Papers 22 | 23 | http://resources.mpi-inf.mpg.de/ProjectiveBlueNoise/ - "Projective Blue-Noise Sampling " from 2015 -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: main.cpp 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | */ 6 | 7 | #include "shared/datacache.h" 8 | #include "codegen.h" 9 | 10 | #include "families/_1d/samples/blue_noise/manual_test.h" 11 | #include "families/_1d/tests/integration/manual_test.h" 12 | #include "families/_2d/tests/integration/manual_test.h" 13 | 14 | void ManualTest() 15 | { 16 | _1d::Tests::Integration::ManualTest(); 17 | _1d::Samples::BlueNoise::ManualTest(); 18 | _2d::Tests::Integration::ManualTest(); 19 | } 20 | 21 | int main(int argc, char **argv) 22 | { 23 | DataCache::Load(); 24 | 25 | // Note: comment this out and call your specific code directly if you want to iterate on code. 26 | // You can also pop open samples.cpp and comment out sampling types . 27 | // You can also follow this function call down to see what is actually called and comment out the tests (or family of tests) that you don't want it to do while you iterate. 28 | // Any modifications you make to those files will be undone when you run premake and re-generate code and documentation. 29 | _1d::Tests::AutoTest(); 30 | _2d::Tests::AutoTest(); 31 | ManualTest(); 32 | 33 | DataCache::Save(); 34 | return 0; 35 | } 36 | 37 | /* 38 | 39 | For sure TODO: 40 | 41 | ? is hammerlsey ok with tests doing non power of 2 sample counts on it? i think probably not, but check out what it's actually doing. 42 | * like for integration and discrepancy tests 43 | 44 | * make 2d/1d tests deal with randomized sequences appropriately? (integration might be hard... lots of samples needing to be generated. hard for blue noise) 45 | * i wonder if the blue noise speedup idea you have would be any better? not for 2d.... 46 | * maybe just have discrepancy deal with randomization. integration has lots of samples so kinda handles randomization in that sense already. 47 | 48 | 49 | backlog TODO: 50 | 51 | * Chebyshev sampling from simd crawford. add to reserach list. 52 | * add to todos to implement and analyze 2) (t,s)-sequences and (t,m,s)-nets; and 3) lattices 53 | * there are a lot of disk sampling and other things in the progressive projective blue noise code. 54 | 55 | * Make a 1d and 2d generic readme to explain when they are used and also to put hand picked global results and analysis in. intro section per family? 56 | * samples in 1d / 2d: need a "comparison vs others" section. to showcase vs worse (worst?) and better (best?) of the family 57 | 58 | 59 | 60 | 61 | 62 | Docs: 63 | ! hammersley: if you skip index 0, it doesn't help anything, because you then get the zero from the next sequence! This unless you do N-1 sample items, which is kind of weird and doesn't really help anything. 64 | * n rooks -> followed regular centered offset best practices 65 | * sobol: starts at index 1 because first sample is 0. Sound familiar? 66 | * hammersley offset vs none. getting away from the edges. sound familiar? 67 | 68 | * centralize all explanations that you can. 69 | * link to them from the family specific pages 70 | * make the family specific pages be about technical details specific to that family. 71 | 72 | * hammersley b2 with bit truncation: make sure and trim the bits off the end! 73 | * both hammersley explanations are the same when samples are a power of 2. reversing the bits / treating as fraction, and index/N. same after full set of values anyways. first way gives a better intermediate image. 74 | 75 | * ok, wolfram alpha and wikipedia are not so far off after all... 76 | * both have D-1 axes of halton. 77 | * wolfram says reverse the bits for the second axis 78 | * wikipedia says n/N for the second axis (should we add 1/N*2 ??) 79 | * wolfram also talks about bit truncation. Does that also apply to wikipedia setup? 80 | 81 | * hammersley paper (book) pdf from 1964 82 | * http://www.cs.fsu.edu/~mascagni/Hammersley-Handscomb.pdf 83 | 84 | * I don't think hammersley bit truncation is working correctly. In 8 samples, truncating 1 bit makes there be 4 unique samples. 85 | * hammersley explanation: http://planning.cs.uiuc.edu/node210.html 86 | 87 | * tests in 1d /2d: need to explain how they deal with randomization vs determinism and progressive vs non progressiveness 88 | * test your links on each page, i think some are broken! 89 | */ -------------------------------------------------------------------------------- /src/shared/color_spaces.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: color_spaces.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/10/2019 5 | 6 | Description: 7 | Helper functions to convert between different color spaces 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | #include 15 | #include "math.h" 16 | #include "vector.h" 17 | 18 | inline float LinearToSRGB(float value) 19 | { 20 | return pow(value, 1.0f / 2.2f); 21 | } 22 | 23 | inline float SRGBToLinear(float value) 24 | { 25 | return pow(value, 2.2f); 26 | } 27 | 28 | inline uint8_t FloatToU8(float value) 29 | { 30 | return uint8_t(value * 255.0f + 0.5f); 31 | } 32 | 33 | // adapted from https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/ 34 | inline Vec3 HUEtoRGB(float H) 35 | { 36 | float R = Clamp(abs(H * 6 - 3) - 1, 0.0f, 1.0f); 37 | float G = Clamp(2 - abs(H * 6 - 2), 0.0f, 1.0f); 38 | float B = Clamp(2 - abs(H * 6 - 4), 0.0f, 1.0f); 39 | return Vec3{ R, G, B }; 40 | } 41 | 42 | inline Vec3 HSVToRGB(Vec3 HSV) 43 | { 44 | Vec3 RGB = HUEtoRGB(HSV[0]); 45 | return ((RGB - 1.0f) * HSV[1] + 1.0f) * HSV[2]; 46 | } 47 | -------------------------------------------------------------------------------- /src/shared/drawing.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: drawing.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | 6 | Description: 7 | Some helper functions for drawing 2d images 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "pixel.h" 13 | #include "vector.h" 14 | 15 | struct Image; 16 | 17 | void DrawLine(Image& image, float x1, float y1, float x2, float y2, const PixelRGBAF32& color, float lineWidth); 18 | void DrawBox(Image& image, const Vec2& min, const Vec2& max, const PixelRGBAF32& color); 19 | void DrawCircle(Image& image, const Vec2& pos, float radius, const PixelRGBAF32& color); 20 | -------------------------------------------------------------------------------- /src/shared/drawtext.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: drawtext.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/16/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "image.h" 10 | #include "vector.h" 11 | 12 | Image MakeTextImage(const char* string, PixelRGBAF32 color, float textHeight, int& baseline); 13 | 14 | enum class TextHAlign 15 | { 16 | Left, 17 | Right, 18 | Center 19 | }; 20 | 21 | enum class TextVAlign 22 | { 23 | Top, 24 | Bottom, 25 | Center 26 | }; 27 | 28 | void DrawText(Image& image, const char* string, PixelRGBAF32 color, float textHeight, Vec2& pos, TextHAlign halign, TextVAlign valign); 29 | -------------------------------------------------------------------------------- /src/shared/fnv1a.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: fnv1a.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/26/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | // default values recommended by http://isthe.com/chongo/tech/comp/fnv/ 10 | static const uint32_t Prime = 0x01000193; // 16777619 11 | static const uint32_t Seed = 0x811C9DC5; // 2166136261 12 | /// hash a single byte 13 | static inline uint32_t fnv1a(unsigned char oneByte, uint32_t hash = Seed) 14 | { 15 | return (oneByte ^ hash) * Prime; 16 | } 17 | 18 | /// hash a block of memory 19 | static inline uint32_t fnv1a(const void* data, size_t numBytes, uint32_t hash = Seed) 20 | { 21 | const unsigned char* ptr = (const unsigned char*)data; 22 | while (numBytes--) 23 | hash = fnv1a(*ptr++, hash); 24 | return hash; 25 | } -------------------------------------------------------------------------------- /src/shared/graph.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: graph.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/17/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include "vector.h" 12 | #include "drawtext.h" 13 | #include 14 | 15 | typedef std::function TGraphContinuousCallback; 16 | 17 | struct GraphItem 18 | { 19 | std::string label; 20 | std::vector data; 21 | }; 22 | 23 | struct GraphAxisTick 24 | { 25 | float value; 26 | std::string label; 27 | TextHAlign halign; 28 | TextVAlign valign; 29 | }; 30 | 31 | enum class GraphType 32 | { 33 | Lines, 34 | Points, 35 | Continuous 36 | }; 37 | 38 | struct GraphDesc 39 | { 40 | GraphType graphType = GraphType::Lines; 41 | const char* fileName = nullptr; 42 | const char* title = nullptr; 43 | const char* footer = nullptr; 44 | std::vector graphItems; 45 | std::vector xAxisTicks; 46 | std::vector yAxisTicks; 47 | int intermediateWidth = 1024; // rendered at this size if nonzero. else rendered at width size 48 | int width = 512; // scaled to this size 49 | bool loglog = false; 50 | Vec2 minPad = Vec2{ 0.0f, 0.0f }; 51 | Vec2 maxPad = Vec2{ 0.0f, 0.0f }; 52 | bool forceYMinMax = false; 53 | Vec2 yMinMax = Vec2{ 0.0f, 0.0f }; 54 | bool forceXMinMax = false; 55 | Vec2 xMinMax = Vec2{ 0.0f, 0.0f }; 56 | TGraphContinuousCallback continuousCallback = nullptr; 57 | }; 58 | 59 | void MakeGraph(const GraphDesc& desc); 60 | -------------------------------------------------------------------------------- /src/shared/image.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: image.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | 6 | Description: 7 | A thin wrapper to some pixels, and a way to save them to disk as an image 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "pixel.h" 13 | #include 14 | 15 | // Images are RGBAF32, and are stored as premultiplied alpha 16 | 17 | struct Image 18 | { 19 | Image() 20 | { 21 | m_width = 0; 22 | m_height = 0; 23 | } 24 | 25 | Image(int width, int height, PixelRGBAF32 clearColor = PixelRGBAF32(1.0f, 1.0f, 1.0f, 1.0f)) 26 | { 27 | Resize(width, height, clearColor); 28 | } 29 | 30 | void Resize(int width, int height, PixelRGBAF32 clearColor = PixelRGBAF32(1.0f, 1.0f, 1.0f, 1.0f)) 31 | { 32 | m_width = width; 33 | m_height = height; 34 | m_pixels.resize(m_width*m_height); 35 | std::fill(m_pixels.begin(), m_pixels.end(), PixelRGBAF32_PMA(clearColor)); 36 | } 37 | 38 | PixelRGBAF32_PMA GetPixelClamped(int x, int y) 39 | { 40 | x = Clamp(x, 0, m_width - 1); 41 | y = Clamp(y, 0, m_height - 1); 42 | 43 | return m_pixels[y * m_width + x]; 44 | } 45 | 46 | int m_width; 47 | int m_height; 48 | std::vector m_pixels; 49 | }; 50 | 51 | void SaveImage(const Image& image, const char* fileName); 52 | 53 | void BlendInImage(Image& image, const Image& otherImage, int pastex, int pastey); 54 | 55 | void BlendInImage_Resize(Image& image, const Image& otherImage, unsigned int pastex, unsigned int pastey, PixelRGBAF32 clearColor); 56 | 57 | void ResizeImageBicubic(Image& image, int newWidth, int newHeight); 58 | 59 | PixelRGBAF32_PMA SampleImageBicubic(Image& image, Vec2 uv); 60 | -------------------------------------------------------------------------------- /src/shared/math.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: math.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/10/2019 5 | */ 6 | 7 | # pragma once 8 | 9 | #include 10 | 11 | inline float SmoothStep(float value, float min, float max) 12 | { 13 | float x = (value - min) / (max - min); 14 | x = std::min(x, 1.0f); 15 | x = std::max(x, 0.0f); 16 | 17 | return 3.0f * x * x - 2.0f * x * x * x; 18 | } 19 | 20 | template 21 | T Lerp(T A, T B, float t) 22 | { 23 | return T(float(A) * (1.0f - t) + float(B) * t); 24 | } 25 | 26 | template 27 | T Clamp(T Value, T Min, T Max) 28 | { 29 | if (Value <= Min) 30 | return Min; 31 | else if (Value >= Max) 32 | return Max; 33 | else 34 | return Value; 35 | } 36 | 37 | // t is a value that goes from 0 to 1 to interpolate in a C1 continuous way across uniformly sampled data points. 38 | // when t is 0, this will return B. When t is 1, this will return C. Inbetween values will return an interpolation 39 | // between B and C. A and D are used to calculate slopes at the edges. 40 | template 41 | T CubicHermite (T A, T B, T C, T D, float t) 42 | { 43 | T a = -A / 2.0f + (3.0f*B) / 2.0f - (3.0f*C) / 2.0f + D / 2.0f; 44 | T b = A - (5.0f*B) / 2.0f + 2.0f*C - D / 2.0f; 45 | T c = -A / 2.0f + C / 2.0f; 46 | T d = B; 47 | 48 | return a*t*t*t + b*t*t + c*t + d; 49 | } 50 | -------------------------------------------------------------------------------- /src/shared/pixel.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: pixel.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/8/2019 5 | 6 | Description: 7 | defines the types used to represent a pixel. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include "math.h" 14 | #include "vector.h" 15 | #include "color_spaces.h" 16 | 17 | struct PixelRGBAF32_PMA; 18 | 19 | struct PixelRGBAU8 20 | { 21 | PixelRGBAU8(uint8_t r_ = 0, uint8_t g_ = 0, uint8_t b_ = 0, uint8_t a_ = 255) 22 | { 23 | r = r_; 24 | g = g_; 25 | b = b_; 26 | a = a_; 27 | } 28 | uint8_t r, g, b, a; 29 | 30 | // allow explicit conversion from PMA to RGBAU8 31 | explicit inline PixelRGBAU8(const PixelRGBAF32_PMA& src); 32 | }; 33 | 34 | struct PixelRGBAF32 35 | { 36 | PixelRGBAF32(float r_ = 0.0f, float g_ = 0.0f, float b_ = 0.0f, float a_ = 1.0f) 37 | { 38 | r = r_; 39 | g = g_; 40 | b = b_; 41 | a = a_; 42 | } 43 | float r, g, b, a; 44 | 45 | // allow explicit conversion from PMA to non PMA 46 | explicit inline PixelRGBAF32(const PixelRGBAF32_PMA& src); 47 | }; 48 | 49 | struct PixelRGBAF32_PMA 50 | { 51 | PixelRGBAF32_PMA(float r_ = 0.0f, float g_ = 0.0f, float b_ = 0.0f, float a_ = 1.0f) 52 | { 53 | r = r_; 54 | g = g_; 55 | b = b_; 56 | a = a_; 57 | } 58 | 59 | void BlendIn(const PixelRGBAF32_PMA& color) 60 | { 61 | r = color.r + r * (1.0f - color.a); 62 | g = color.g + g * (1.0f - color.a); 63 | b = color.b + b * (1.0f - color.a); 64 | a = color.a + a * (1.0f - color.a); 65 | } 66 | 67 | void MultiplyAlpha(float alpha) 68 | { 69 | r *= alpha; 70 | g *= alpha; 71 | b *= alpha; 72 | a *= alpha; 73 | } 74 | 75 | Vec4 ToVec4() 76 | { 77 | Vec4 ret; 78 | ret[0] = r; 79 | ret[1] = g; 80 | ret[2] = b; 81 | ret[3] = a; 82 | return ret; 83 | } 84 | 85 | void FromVec4(const Vec4& v) 86 | { 87 | r = v[0]; 88 | g = v[1]; 89 | b = v[2]; 90 | a = v[3]; 91 | } 92 | 93 | float r, g, b, a; 94 | 95 | // allow explicit conversion from non PMA to PMA 96 | explicit inline PixelRGBAF32_PMA(const PixelRGBAF32& src); 97 | }; 98 | 99 | inline PixelRGBAU8::PixelRGBAU8(const PixelRGBAF32_PMA& src) 100 | { 101 | PixelRGBAF32 srcNonPMA(src); 102 | 103 | float r_ = LinearToSRGB(Clamp(srcNonPMA.r, 0.0f, 1.0f)); 104 | float g_ = LinearToSRGB(Clamp(srcNonPMA.g, 0.0f, 1.0f)); 105 | float b_ = LinearToSRGB(Clamp(srcNonPMA.b, 0.0f, 1.0f)); 106 | float a_ = Clamp(srcNonPMA.a, 0.0f, 1.0f); 107 | 108 | r = uint8_t(r_*255.0f + 0.5f); 109 | g = uint8_t(g_*255.0f + 0.5f); 110 | b = uint8_t(b_*255.0f + 0.5f); 111 | a = uint8_t(a_*255.0f + 0.5f); 112 | } 113 | 114 | inline PixelRGBAF32_PMA::PixelRGBAF32_PMA(const PixelRGBAF32& src) 115 | { 116 | r = src.r * src.a; 117 | g = src.g * src.a; 118 | b = src.b * src.a; 119 | a = src.a; 120 | } 121 | 122 | inline PixelRGBAF32::PixelRGBAF32(const PixelRGBAF32_PMA& src) 123 | { 124 | if (src.a > 0.0f) 125 | { 126 | r = src.r / src.a; 127 | g = src.g / src.a; 128 | b = src.b / src.a; 129 | } 130 | else 131 | { 132 | r = 0.0f; 133 | g = 0.0f; 134 | b = 0.0f; 135 | } 136 | a = src.a; 137 | } -------------------------------------------------------------------------------- /src/shared/vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | FILE: vector.h 3 | AUTHOR: Alan Wolfe (alan.wolfe@gmail.com) 4 | DATE: 2/18/2019 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | typedef std::array Vec2; 12 | typedef std::array Vec3; 13 | typedef std::array Vec4; 14 | 15 | // Unary minus 16 | template 17 | inline std::array operator-(const std::array& A) 18 | { 19 | std::array ret; 20 | for (size_t i = 0; i < N; ++i) 21 | ret[i] = -A[i]; 22 | return ret; 23 | } 24 | 25 | // Vec Vec 26 | 27 | template 28 | inline std::array operator - (const std::array& A, const std::array& B) 29 | { 30 | std::array ret; 31 | for (size_t i = 0; i < N; ++i) 32 | ret[i] = A[i] - B[i]; 33 | return ret; 34 | } 35 | 36 | template 37 | inline std::array operator + (const std::array& A, const std::array& B) 38 | { 39 | std::array ret; 40 | for (size_t i = 0; i < N; ++i) 41 | ret[i] = A[i] + B[i]; 42 | return ret; 43 | } 44 | 45 | template 46 | inline std::array operator * (const std::array& A, const std::array& B) 47 | { 48 | std::array ret; 49 | for (size_t i = 0; i < N; ++i) 50 | ret[i] = A[i] * B[i]; 51 | return ret; 52 | } 53 | 54 | template 55 | inline std::array operator / (const std::array& A, const std::array& B) 56 | { 57 | std::array ret; 58 | for (size_t i = 0; i < N; ++i) 59 | ret[i] = A[i] / B[i]; 60 | return ret; 61 | } 62 | 63 | // Vec op Scalar 64 | // Scalar op Vec 65 | 66 | template 67 | inline std::array operator * (const std::array& A, float B) 68 | { 69 | std::array ret; 70 | for (size_t i = 0; i < N; ++i) 71 | ret[i] = A[i] * B; 72 | return ret; 73 | } 74 | 75 | template 76 | inline std::array operator * (float B, const std::array& A) 77 | { 78 | std::array ret; 79 | for (size_t i = 0; i < N; ++i) 80 | ret[i] = A[i] * B; 81 | return ret; 82 | } 83 | 84 | template 85 | inline std::array operator / (const std::array& A, float B) 86 | { 87 | std::array ret; 88 | for (size_t i = 0; i < N; ++i) 89 | ret[i] = A[i] / B; 90 | return ret; 91 | } 92 | 93 | template 94 | inline std::array operator - (const std::array& A, float B) 95 | { 96 | std::array ret; 97 | for (size_t i = 0; i < N; ++i) 98 | ret[i] = A[i] - B; 99 | return ret; 100 | } 101 | 102 | template 103 | inline std::array operator + (const std::array& A, float B) 104 | { 105 | std::array ret; 106 | for (size_t i = 0; i < N; ++i) 107 | ret[i] = A[i] + B; 108 | return ret; 109 | } 110 | 111 | // Other 112 | 113 | template 114 | inline float DistanceUnitTorroidal(const std::array& A, const std::array& B) 115 | { 116 | float axisDistSquaredSum = 0.0f; 117 | for (size_t i = 0; i < N; ++i) 118 | { 119 | float axisDist = B[i] - A[i]; 120 | if (axisDist > 0.5f) 121 | axisDist = 1.0f - axisDist; 122 | axisDistSquaredSum += axisDist * axisDist; 123 | } 124 | return sqrtf(axisDistSquaredSum); 125 | } 126 | -------------------------------------------------------------------------------- /src/simple_fft/error_handling.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SIMPLE_FFT__ERROR_HANDLING_HPP 2 | #define __SIMPLE_FFT__ERROR_HANDLING_HPP 3 | 4 | namespace simple_fft { 5 | namespace error_handling { 6 | 7 | enum EC_SimpleFFT 8 | { 9 | EC_SUCCESS = 0, 10 | EC_UNSUPPORTED_DIMENSIONALITY, 11 | EC_WRONG_FFT_DIRECTION, 12 | EC_ONE_OF_DIMS_ISNT_POWER_OF_TWO, 13 | EC_NUM_OF_ELEMS_IS_ZERO, 14 | EC_WRONG_CHECK_FFT_MODE, 15 | EC_RELATIVE_ERROR_TOO_LARGE 16 | }; 17 | 18 | inline void GetErrorDescription(const EC_SimpleFFT error_code, 19 | const char *& error_description) 20 | { 21 | switch(error_code) 22 | { 23 | case EC_SUCCESS: 24 | error_description = "Calculation was successful!"; 25 | break; 26 | case EC_UNSUPPORTED_DIMENSIONALITY: 27 | error_description = "Unsupported dimensionality: currently only 1D, 2D " 28 | "and 3D arrays are supported"; 29 | break; 30 | case EC_WRONG_FFT_DIRECTION: 31 | error_description = "Wrong direction for FFT was specified"; 32 | break; 33 | case EC_ONE_OF_DIMS_ISNT_POWER_OF_TWO: 34 | error_description = "Unsupported dimensionality: one of dimensions is not " 35 | "a power of 2"; 36 | break; 37 | case EC_NUM_OF_ELEMS_IS_ZERO: 38 | error_description = "Number of elements for FFT or IFFT is zero!"; 39 | break; 40 | case EC_WRONG_CHECK_FFT_MODE: 41 | error_description = "Wrong check FFT mode was specified (should be either " 42 | "Parseval theorem or energy conservation check"; 43 | break; 44 | case EC_RELATIVE_ERROR_TOO_LARGE: 45 | error_description = "Relative error returned by FFT test exceeds specified " 46 | "relative tolerance"; 47 | break; 48 | default: 49 | error_description = "Unknown error"; 50 | break; 51 | } 52 | } 53 | 54 | } // namespace error_handling 55 | } // namespace simple_fft 56 | 57 | #endif // __SIMPLE_FFT__ERROR_HANDLING_HPP 58 | -------------------------------------------------------------------------------- /src/simple_fft/fft_settings.h: -------------------------------------------------------------------------------- 1 | // In this file you can alter some settings of the library: 2 | // 1) Specify the desired real and complex types by typedef'ing real_type and complex_type. 3 | // By default real_type is double and complex_type is std::complex. 4 | // 2) If the array class uses square brackets for element access operator, define 5 | // the macro __USE_SQUARE_BRACKETS_FOR_ELEMENT_ACCESS_OPERATOR 6 | 7 | #ifndef __SIMPLE_FFT__FFT_SETTINGS_H__ 8 | #define __SIMPLE_FFT__FFT_SETTINGS_H__ 9 | 10 | #include 11 | 12 | typedef double real_type; 13 | typedef std::complex complex_type; 14 | 15 | //#ifndef __USE_SQUARE_BRACKETS_FOR_ELEMENT_ACCESS_OPERATOR 16 | //#define __USE_SQUARE_BRACKETS_FOR_ELEMENT_ACCESS_OPERATOR 17 | //#endif 18 | 19 | #endif // __SIMPLE_FFT__FFT_SETTINGS_H__ 20 | -------------------------------------------------------------------------------- /toc.md: -------------------------------------------------------------------------------- 1 | ## _1d Samples 2 | 3 | * [Blue Noise](output/_1d/samples/blue_noise/page.md) - Randomized sequences that have only high frequency content 4 | * [Irrational Numbers](output/_1d/samples/irrational_numbers/page.md) - Multiply an irrational number by the squence index and take that mod 1 to make it be in [0,1) 5 | * [LDS](output/_1d/samples/lds/page.md) - Low discrepancy sequences 6 | * [Regular](output/_1d/samples/regular/page.md) - Uniformly spaced samples 7 | * [Uniform Random](output/_1d/samples/uniform_random/page.md) - Randomized sample positions using a uniform random number distribution. 8 | ## _1d Tests 9 | 10 | * [DFT](output/_1d/tests/dft/page.md) - Transforms sampling patterns into frequency space 11 | * [Discrepancy](output/_1d/tests/discrepancy/page.md) - Calculate metrics about actual point density compared to expected point density if the points were uniformly spaced. 12 | * [Integration](output/_1d/tests/integration/page.md) - Use sample points to integrate 1d functions 13 | * [Numberline](output/_1d/tests/numberline/page.md) - Makes numberlines 14 | ## _2d Samples 15 | 16 | * [Blue Noise](output/_2d/samples/blue_noise/page.md) - Randomized sequences that have only high frequency content 17 | * [Irrational Numbers](output/_2d/samples/irrational_numbers/page.md) - Using irrational numbers to make 2d low discrepancy sequences 18 | * [LDS](output/_2d/samples/lds/page.md) - Low discrepancy sequences 19 | * [Hammersley (LDS)](output/_2d/samples/lds_hammersley/page.md) - Low discrepancy sequences 20 | * [Regular](output/_2d/samples/regular/page.md) - Uniformly spaced samples 21 | * [Uniform Random](output/_2d/samples/uniform_random/page.md) - Randomized sample positions using a uniform random number distribution. 22 | ## _2d Tests 23 | 24 | * [DFT](output/_2d/tests/dft/page.md) - Transforms sampling patterns into frequency space 25 | * [Discrepancy](output/_2d/tests/discrepancy/page.md) - Calculate metrics about actual point density compared to expected point density if the points were uniformly spaced. 26 | * [Integration](output/_2d/tests/integration/page.md) - Use sample points to integrate 2d functions 27 | * [Plot](output/_2d/tests/plot/page.md) - Plots sequences 28 | --------------------------------------------------------------------------------