Skip to main content
Log in

Exact Sampling Algorithms for Latin Squares and Sudoku Matrices via Probabilistic Divide-and-Conquer

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

We provide several algorithms for the exact, uniform random sampling of Latin squares and Sudoku matrices via probabilistic divide-and-conquer (PDC). Our approach divides the sample space into smaller pieces, samples each separately, and combines them in a manner which yields an exact sample from the target distribution. We demonstrate, in particular, a version of PDC in which one of the pieces is sampled using a brute force approach, which we dub almost deterministic second half, as it is a generalization to a previous application of PDC for which one of the pieces is uniquely determined given the others.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

Notes

  1. This number can be simplified to 71 after taking more symmetries into account [18].

  2. 1.8 GHz Intel Core i7.

References

  1. Arratia, R., DeSalvo, S.: Poisson and independent process approximation for random combinatorial structures with a given number of components, and near-universal behavior for low rank assemblies. arXiv preprint arXiv:1606.04642 (2016)

  2. Arratia, R., DeSalvo, S.: Probabilistic divide-and-conquer: a new exact simulation method, with integer partitions as an example. Comb. Probab. Comput. 25(3), 324–351 (2016)

    Article  MathSciNet  Google Scholar 

  3. Colbourn, C.J.: The complexity of completing partial latin squares. Discrete Appl. Math. 8(1), 25–30 (1984)

    Article  MathSciNet  MATH  Google Scholar 

  4. Dahl, G.: Permutation matrices related to sudoku. Linear Algebra Appl. 430(8), 2457–2463 (2009)

    Article  MathSciNet  MATH  Google Scholar 

  5. DeSalvo, S.: Probabilistic divide-and-conquer: deterministic second half. arXiv preprint arXiv:1411.6698 (2014)

  6. DeSalvo, S.: Improvements to exact Boltzmann sampling using probabilistic divide-and-conquer and the recursive method. arXiv preprint arXiv:1608.07922 (2016)

  7. Devroye, L.: Nonuniform random variate generation. Handb. Oper. Res Manag. Sci. 13, 83–121 (2006)

    Article  Google Scholar 

  8. Diaconis, P., Sturmfels, B., et al.: Algebraic algorithms for sampling from conditional distributions. Ann. Stat. 26(1), 363–397 (1998)

    Article  MathSciNet  MATH  Google Scholar 

  9. Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Boltzmann samplers for the random generation of combinatorial structures. Combin. Probab. Comput. 13(4–5), 577–625 (2004)

    Article  MathSciNet  MATH  Google Scholar 

  10. Felgenhauer, B., Jarvis, F.: Mathematics of sudoku i. Math. Spectr. 39(1), 15–22 (2006)

    Google Scholar 

  11. Flajolet, P., Sedgewick, R.: Analytic Combinatorics. Cambridge University Press, Cambridge (2009)

    Book  MATH  Google Scholar 

  12. Fontana, R.: Fractions of permutations. an application to sudoku. J. Stat. Plan. Inference 141(12), 3697–3704 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  13. Fontana, R.: Random latin squares and sudoku designs generation. arXiv preprint arXiv:1305.3697 (2013)

  14. Fontana, R., Rapallo, F., Rogantin, M.P.: Markov bases for sudoku grids. In: Advanced Statistical Methods for the Analysis of Large Data-Sets, pages 305–315. Springer, (2012)

  15. Godsil, C.D., McKay, B.D.: Asymptotic enumeration of latin rectangles. J. Comb. Theory Ser. B 48(1), 19–44 (1990)

    Article  MathSciNet  MATH  Google Scholar 

  16. Huber, M.L.: Perfect Simulation. Chapman & Hall/CRC Monographs on Statistics & Applied Probability. Taylor & Francis, (2015)

  17. Jacobson, M.T., Matthews, P.: Generating uniformly distributed random latin squares. J. Comb. Des. 4(6), 405–437 (1996)

    Article  MathSciNet  MATH  Google Scholar 

  18. Jarvis, F..: Website of Frazer Jarvis. http://www.afjarvis.staff.shef.ac.uk/sudoku/bertram.html (2005)

  19. Jerrum, M., Sinclair, A., Vigoda, E.: A polynomial-time approximation algorithm for the permanent of a matrix with nonnegative entries. J. ACM 51(4), 671–697 (2004). (electronic)

    Article  MathSciNet  MATH  Google Scholar 

  20. Levin, D.A., Peres, Y., Wilmer, E.L.: Markov Chains and Mixing Times. American Mathematical Soc, Providence (2009)

    MATH  Google Scholar 

  21. Newton, P.K., DeSalvo, S.A.: The shannon entropy of sudoku matrices. In: Proceedings of the Royal Society of London A: Mathematical, Physical and Engineering Sciences, page rspa20090522. The Royal Society (2010)

  22. Nijenhuis, A., Wilf, H.S.: A method and two algorithms on the theory of partitions. J. Comb. Theory Ser. A 18, 219–222 (1975)

    Article  MathSciNet  MATH  Google Scholar 

  23. Nijenhuis, A., Wilf, H.S.: Combinatorial algorithms. Academic Press, Inc. [Harcourt Brace Jovanovich, Publishers], New York-London, second edition, 1978. For computers and calculators, Computer Science and Applied Mathematics (1978)

  24. Random Struct. Algor. Exact sampling with coupled markov chains and applications to statistical mechanics. 9(1–2), 223–252 (1996)

  25. Ridder, A.: Counting the number of sudoku’s by importance sampling simulation (2013)

  26. Russell, E., Jarvis, F.: Mathematics of sudoku II. Math. Spectr. 39(2), 54–58 (2006)

    Google Scholar 

  27. Sloane, N.J.A.: Online Encyclopedia of Integer Sequences. Published electronically at http://www.oeis.org/

  28. Stones, D.S.: The many formulae for the number of Latin rectangles. Electron. J. Comb. 17(1), Article 1 46 (2010)

    MathSciNet  MATH  Google Scholar 

  29. van Lint, J.H., Wilson, R.M.: A Course in Combinatorics, 2nd edn. Cambridge University Press, Cambridge (2001)

    Book  MATH  Google Scholar 

  30. Von Neumann, J.: Various techniques used in connection with random digits. Appl. Math Ser. 12(36–38), 1 (1951)

    Google Scholar 

  31. Yordzhev, K.: On the number of disjoint pairs of s-permutation matrices. Discrete Appl. Math. 161(18), 3072–3079 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  32. Yordzhev, K.: Random permutations, random sudoku matrices and randomized algorithms. arXiv preprint arXiv:1312.0192, (2013)

Download references

Acknowledgments

The author would like to acknowledge helpful conversations with James Zhao and Edo Liberty, and also helpful comments from an anonymous reviewer.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Stephen DeSalvo.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

DeSalvo, S. Exact Sampling Algorithms for Latin Squares and Sudoku Matrices via Probabilistic Divide-and-Conquer. Algorithmica 79, 742–762 (2017). https://doi.org/10.1007/s00453-016-0223-y

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-016-0223-y

Keywords

Mathematics Subject Classification

Navigation