How to create the random numbers with PSTricks?











up vote
5
down vote

favorite












The TikZ code of Schulte Table (Tran Le Nam's author):



documentclass[12pt,tikz,border=3mm]{standalone}
usetikzlibrary{calc}
usepackage{xstring}
begin{document}
large
begin{tikzpicture}
defn{5}
defmylist{}
pgfmathsetmacro{numbermax}{n*n}
foreach x in {1,...,numbermax}{
xdefmylist{mylistnoexpand{xnoexpand}}
}
begin{scope}
pgfmathsetmacro{nt}{n-1}
foreach i in {0,...,nt}
{
foreach j in {0,...,nt}
{ pgfmathdeclarerandomlist{mynum}{mylist}
pgfmathrandomitem{mynum}{mynum}
StrSubstitute{mylist}{{mynum}}{}[sublist]
globalletmylistsublist
pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
definecolor{mau}{rgb}{maum,mauh,0.1}
node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
}
}
draw (0,0) grid (n,n);
end{scope}
end{tikzpicture}
end{document}


enter image description here



Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?










share|improve this question




























    up vote
    5
    down vote

    favorite












    The TikZ code of Schulte Table (Tran Le Nam's author):



    documentclass[12pt,tikz,border=3mm]{standalone}
    usetikzlibrary{calc}
    usepackage{xstring}
    begin{document}
    large
    begin{tikzpicture}
    defn{5}
    defmylist{}
    pgfmathsetmacro{numbermax}{n*n}
    foreach x in {1,...,numbermax}{
    xdefmylist{mylistnoexpand{xnoexpand}}
    }
    begin{scope}
    pgfmathsetmacro{nt}{n-1}
    foreach i in {0,...,nt}
    {
    foreach j in {0,...,nt}
    { pgfmathdeclarerandomlist{mynum}{mylist}
    pgfmathrandomitem{mynum}{mynum}
    StrSubstitute{mylist}{{mynum}}{}[sublist]
    globalletmylistsublist
    pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
    pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
    definecolor{mau}{rgb}{maum,mauh,0.1}
    node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
    }
    }
    draw (0,0) grid (n,n);
    end{scope}
    end{tikzpicture}
    end{document}


    enter image description here



    Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?










    share|improve this question


























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      The TikZ code of Schulte Table (Tran Le Nam's author):



      documentclass[12pt,tikz,border=3mm]{standalone}
      usetikzlibrary{calc}
      usepackage{xstring}
      begin{document}
      large
      begin{tikzpicture}
      defn{5}
      defmylist{}
      pgfmathsetmacro{numbermax}{n*n}
      foreach x in {1,...,numbermax}{
      xdefmylist{mylistnoexpand{xnoexpand}}
      }
      begin{scope}
      pgfmathsetmacro{nt}{n-1}
      foreach i in {0,...,nt}
      {
      foreach j in {0,...,nt}
      { pgfmathdeclarerandomlist{mynum}{mylist}
      pgfmathrandomitem{mynum}{mynum}
      StrSubstitute{mylist}{{mynum}}{}[sublist]
      globalletmylistsublist
      pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
      pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
      definecolor{mau}{rgb}{maum,mauh,0.1}
      node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
      }
      }
      draw (0,0) grid (n,n);
      end{scope}
      end{tikzpicture}
      end{document}


      enter image description here



      Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?










      share|improve this question















      The TikZ code of Schulte Table (Tran Le Nam's author):



      documentclass[12pt,tikz,border=3mm]{standalone}
      usetikzlibrary{calc}
      usepackage{xstring}
      begin{document}
      large
      begin{tikzpicture}
      defn{5}
      defmylist{}
      pgfmathsetmacro{numbermax}{n*n}
      foreach x in {1,...,numbermax}{
      xdefmylist{mylistnoexpand{xnoexpand}}
      }
      begin{scope}
      pgfmathsetmacro{nt}{n-1}
      foreach i in {0,...,nt}
      {
      foreach j in {0,...,nt}
      { pgfmathdeclarerandomlist{mynum}{mylist}
      pgfmathrandomitem{mynum}{mynum}
      StrSubstitute{mylist}{{mynum}}{}[sublist]
      globalletmylistsublist
      pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
      pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
      definecolor{mau}{rgb}{maum,mauh,0.1}
      node[color=mau] at ($ (i+0.5, j+0.5 ) $) {mynum};
      }
      }
      draw (0,0) grid (n,n);
      end{scope}
      end{tikzpicture}
      end{document}


      enter image description here



      Truly, until now, I don't know about "the random syntax" in any PSTricks documentations. Can I find "the random syntax" in where?







      macros pstricks






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 12 mins ago

























      asked 2 days ago









      chishimotoji

      621212




      621212






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          Does not work with xelatex (it doesn't know the random function)



          documentclass[12pt]{article}
          usepackage{pstricks,pst-calculate,multido}
          usepackage{auto-pst-pdf}
          definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
          begin{document}

          defn{5}
          begin{pspicture}(n,n)
          psgrid[subgriddiv=0,gridlabels=0pt]
          resetcolorseries[25]{test}
          multido{rRow=0.5+1.0}{n}{%
          multido{rCol=0.5+1.0}{n}{%
          rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
          }}
          end{pspicture}

          end{document}


          enter image description here



          And a solution with single random numbers. The random stuff will move into the
          pst-math package tomorrow. Then the code will be easier.



          documentclass[12pt]{article}
          usepackage{pst-calculate}
          usepackage{pstricks,multido}

          definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
          newcounter{RandNo}setcounter{RandNo}{1}
          edefNumbers{pscalculate{randint(1,25)}}

          defgetNoList{%
          edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
          addNumber{Number}Numbers!!}
          defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
          defaddNumberA#1;#2,#3,#4relax{%
          ifxrelax#2relax % we found new number
          xdefNumbers{Numbers,#1}%
          stepcounter{RandNo}%
          ifnumtheRandNo>25 defnext{}% Neue Zahl?
          else defnext{getNoList}fi%
          else
          ifnum#1=#2 % no new number
          defnext{getNoList}%
          else
          ifxrelax#3relax
          defnext{addNumberA#1;,,relax}%
          else %
          defnext{addNumberA#1;#3,#4relax}%
          fi
          fi
          fi
          ifnumtheRandNo<25 next fi
          }
          defgetRandomNo#1{%
          globalcount0 = 1
          edefx{noexpandgetIndex#1;Numbers,,relax}x}
          defgetIndex#1;#2,#3,#4relax{%
          ifnumthecount0=#1
          defnext{#2}%
          else
          globaladvancecount0 by 1
          defnext{getIndex#1;#3,#4relax}%
          fi
          next
          }

          begin{document}
          defn{5}getNoList
          setcounter{RandNo}{1}
          begin{pspicture}(n,n)
          psgrid[subgriddiv=0,gridlabels=0pt]
          resetcolorseries[thenumexprn*n]{test}
          multido{rRow=0.5+1.0}{n}{%
          multido{rCol=0.5+1.0}{n}{%
          rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
          stepcounter{RandNo}%
          }}
          end{pspicture}

          end{document}


          enter image description here






          share|improve this answer























          • What is the syntax random in your answer?
            – chishimotoji
            2 days ago






          • 1




            pscalculate{randint(1,25)} get an integer random between 1 and 25
            – Herbert
            2 days ago










          • Ohh, I see. Thanks.
            – chishimotoji
            2 days ago










          • @chishimotoji: a solution with only numbers from 1..25 after lunch ...
            – Herbert
            2 days ago






          • 1




            usepackage{xcolor} for defining a color series
            – Herbert
            yesterday


















          up vote
          2
          down vote













          A pure PSTricks solution is also possible but we should not reinvent the wheel.



          documentclass[12pt,pstricks,border=1pt]{standalone}
          usepackage{tikz,xstring}
          usetikzlibrary{calc}
          defn{5}defmylist{}

          pgfmathsetmacro{numbermax}{n*n}
          foreach x in {1,...,numbermax}{
          xdefmylist{mylistnoexpand{xnoexpand}}
          }
          pgfmathsetmacro{nt}{n-1}
          newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
          begin{document}
          large
          begin{pspicture}[showgrid](n,n)
          foreach i in {0,...,nt}
          {
          foreach j in {0,...,nt}
          { pgfmathdeclarerandomlist{mynum}{mylist}
          pgfmathrandomitem{mynum}{mynum}
          StrSubstitute{mylist}{{mynum}}{}[sublist]
          globalletmylistsublist
          pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
          pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
          definecolor{mau}{rgb}{maum,mauh,0.1}
          rput(!ispace .5 add jspace .5 add){color{mau}mynum}
          }
          }
          end{pspicture}
          end{document}


          enter image description here



          About Pseudo random generator



          Rand produces a floating point random number between 0 and 1 inclusive and rand produces a "huge" integer.



          documentclass[pstricks,border=12pt,12pt]{standalone}
          pstVerb{realtime srand}

          begin{document}
          begin{pspicture}[showgrid](6,6)
          psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
          end{pspicture}
          end{document}


          enter image description here






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464486%2fhow-to-create-the-random-numbers-with-pstricks%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            Does not work with xelatex (it doesn't know the random function)



            documentclass[12pt]{article}
            usepackage{pstricks,pst-calculate,multido}
            usepackage{auto-pst-pdf}
            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            begin{document}

            defn{5}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[25]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
            }}
            end{pspicture}

            end{document}


            enter image description here



            And a solution with single random numbers. The random stuff will move into the
            pst-math package tomorrow. Then the code will be easier.



            documentclass[12pt]{article}
            usepackage{pst-calculate}
            usepackage{pstricks,multido}

            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            newcounter{RandNo}setcounter{RandNo}{1}
            edefNumbers{pscalculate{randint(1,25)}}

            defgetNoList{%
            edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
            addNumber{Number}Numbers!!}
            defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
            defaddNumberA#1;#2,#3,#4relax{%
            ifxrelax#2relax % we found new number
            xdefNumbers{Numbers,#1}%
            stepcounter{RandNo}%
            ifnumtheRandNo>25 defnext{}% Neue Zahl?
            else defnext{getNoList}fi%
            else
            ifnum#1=#2 % no new number
            defnext{getNoList}%
            else
            ifxrelax#3relax
            defnext{addNumberA#1;,,relax}%
            else %
            defnext{addNumberA#1;#3,#4relax}%
            fi
            fi
            fi
            ifnumtheRandNo<25 next fi
            }
            defgetRandomNo#1{%
            globalcount0 = 1
            edefx{noexpandgetIndex#1;Numbers,,relax}x}
            defgetIndex#1;#2,#3,#4relax{%
            ifnumthecount0=#1
            defnext{#2}%
            else
            globaladvancecount0 by 1
            defnext{getIndex#1;#3,#4relax}%
            fi
            next
            }

            begin{document}
            defn{5}getNoList
            setcounter{RandNo}{1}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[thenumexprn*n]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
            stepcounter{RandNo}%
            }}
            end{pspicture}

            end{document}


            enter image description here






            share|improve this answer























            • What is the syntax random in your answer?
              – chishimotoji
              2 days ago






            • 1




              pscalculate{randint(1,25)} get an integer random between 1 and 25
              – Herbert
              2 days ago










            • Ohh, I see. Thanks.
              – chishimotoji
              2 days ago










            • @chishimotoji: a solution with only numbers from 1..25 after lunch ...
              – Herbert
              2 days ago






            • 1




              usepackage{xcolor} for defining a color series
              – Herbert
              yesterday















            up vote
            4
            down vote



            accepted










            Does not work with xelatex (it doesn't know the random function)



            documentclass[12pt]{article}
            usepackage{pstricks,pst-calculate,multido}
            usepackage{auto-pst-pdf}
            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            begin{document}

            defn{5}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[25]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
            }}
            end{pspicture}

            end{document}


            enter image description here



            And a solution with single random numbers. The random stuff will move into the
            pst-math package tomorrow. Then the code will be easier.



            documentclass[12pt]{article}
            usepackage{pst-calculate}
            usepackage{pstricks,multido}

            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            newcounter{RandNo}setcounter{RandNo}{1}
            edefNumbers{pscalculate{randint(1,25)}}

            defgetNoList{%
            edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
            addNumber{Number}Numbers!!}
            defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
            defaddNumberA#1;#2,#3,#4relax{%
            ifxrelax#2relax % we found new number
            xdefNumbers{Numbers,#1}%
            stepcounter{RandNo}%
            ifnumtheRandNo>25 defnext{}% Neue Zahl?
            else defnext{getNoList}fi%
            else
            ifnum#1=#2 % no new number
            defnext{getNoList}%
            else
            ifxrelax#3relax
            defnext{addNumberA#1;,,relax}%
            else %
            defnext{addNumberA#1;#3,#4relax}%
            fi
            fi
            fi
            ifnumtheRandNo<25 next fi
            }
            defgetRandomNo#1{%
            globalcount0 = 1
            edefx{noexpandgetIndex#1;Numbers,,relax}x}
            defgetIndex#1;#2,#3,#4relax{%
            ifnumthecount0=#1
            defnext{#2}%
            else
            globaladvancecount0 by 1
            defnext{getIndex#1;#3,#4relax}%
            fi
            next
            }

            begin{document}
            defn{5}getNoList
            setcounter{RandNo}{1}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[thenumexprn*n]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
            stepcounter{RandNo}%
            }}
            end{pspicture}

            end{document}


            enter image description here






            share|improve this answer























            • What is the syntax random in your answer?
              – chishimotoji
              2 days ago






            • 1




              pscalculate{randint(1,25)} get an integer random between 1 and 25
              – Herbert
              2 days ago










            • Ohh, I see. Thanks.
              – chishimotoji
              2 days ago










            • @chishimotoji: a solution with only numbers from 1..25 after lunch ...
              – Herbert
              2 days ago






            • 1




              usepackage{xcolor} for defining a color series
              – Herbert
              yesterday













            up vote
            4
            down vote



            accepted







            up vote
            4
            down vote



            accepted






            Does not work with xelatex (it doesn't know the random function)



            documentclass[12pt]{article}
            usepackage{pstricks,pst-calculate,multido}
            usepackage{auto-pst-pdf}
            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            begin{document}

            defn{5}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[25]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
            }}
            end{pspicture}

            end{document}


            enter image description here



            And a solution with single random numbers. The random stuff will move into the
            pst-math package tomorrow. Then the code will be easier.



            documentclass[12pt]{article}
            usepackage{pst-calculate}
            usepackage{pstricks,multido}

            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            newcounter{RandNo}setcounter{RandNo}{1}
            edefNumbers{pscalculate{randint(1,25)}}

            defgetNoList{%
            edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
            addNumber{Number}Numbers!!}
            defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
            defaddNumberA#1;#2,#3,#4relax{%
            ifxrelax#2relax % we found new number
            xdefNumbers{Numbers,#1}%
            stepcounter{RandNo}%
            ifnumtheRandNo>25 defnext{}% Neue Zahl?
            else defnext{getNoList}fi%
            else
            ifnum#1=#2 % no new number
            defnext{getNoList}%
            else
            ifxrelax#3relax
            defnext{addNumberA#1;,,relax}%
            else %
            defnext{addNumberA#1;#3,#4relax}%
            fi
            fi
            fi
            ifnumtheRandNo<25 next fi
            }
            defgetRandomNo#1{%
            globalcount0 = 1
            edefx{noexpandgetIndex#1;Numbers,,relax}x}
            defgetIndex#1;#2,#3,#4relax{%
            ifnumthecount0=#1
            defnext{#2}%
            else
            globaladvancecount0 by 1
            defnext{getIndex#1;#3,#4relax}%
            fi
            next
            }

            begin{document}
            defn{5}getNoList
            setcounter{RandNo}{1}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[thenumexprn*n]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
            stepcounter{RandNo}%
            }}
            end{pspicture}

            end{document}


            enter image description here






            share|improve this answer














            Does not work with xelatex (it doesn't know the random function)



            documentclass[12pt]{article}
            usepackage{pstricks,pst-calculate,multido}
            usepackage{auto-pst-pdf}
            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            begin{document}

            defn{5}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[25]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{pscalculate{randint(1,25)}}}
            }}
            end{pspicture}

            end{document}


            enter image description here



            And a solution with single random numbers. The random stuff will move into the
            pst-math package tomorrow. Then the code will be easier.



            documentclass[12pt]{article}
            usepackage{pst-calculate}
            usepackage{pstricks,multido}

            definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
            newcounter{RandNo}setcounter{RandNo}{1}
            edefNumbers{pscalculate{randint(1,25)}}

            defgetNoList{%
            edefNumber{pscalculate{randint(1,25)}}% Zufallszahl
            addNumber{Number}Numbers!!}
            defaddNumber#1#2!!{edefx{noexpandaddNumberA#1;#2}x,,relax}
            defaddNumberA#1;#2,#3,#4relax{%
            ifxrelax#2relax % we found new number
            xdefNumbers{Numbers,#1}%
            stepcounter{RandNo}%
            ifnumtheRandNo>25 defnext{}% Neue Zahl?
            else defnext{getNoList}fi%
            else
            ifnum#1=#2 % no new number
            defnext{getNoList}%
            else
            ifxrelax#3relax
            defnext{addNumberA#1;,,relax}%
            else %
            defnext{addNumberA#1;#3,#4relax}%
            fi
            fi
            fi
            ifnumtheRandNo<25 next fi
            }
            defgetRandomNo#1{%
            globalcount0 = 1
            edefx{noexpandgetIndex#1;Numbers,,relax}x}
            defgetIndex#1;#2,#3,#4relax{%
            ifnumthecount0=#1
            defnext{#2}%
            else
            globaladvancecount0 by 1
            defnext{getIndex#1;#3,#4relax}%
            fi
            next
            }

            begin{document}
            defn{5}getNoList
            setcounter{RandNo}{1}
            begin{pspicture}(n,n)
            psgrid[subgriddiv=0,gridlabels=0pt]
            resetcolorseries[thenumexprn*n]{test}
            multido{rRow=0.5+1.0}{n}{%
            multido{rCol=0.5+1.0}{n}{%
            rput(rCol,rRow){textcolor{test!!+}{getRandomNo{theRandNo}}}%
            stepcounter{RandNo}%
            }}
            end{pspicture}

            end{document}


            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 2 days ago

























            answered 2 days ago









            Herbert

            267k23407716




            267k23407716












            • What is the syntax random in your answer?
              – chishimotoji
              2 days ago






            • 1




              pscalculate{randint(1,25)} get an integer random between 1 and 25
              – Herbert
              2 days ago










            • Ohh, I see. Thanks.
              – chishimotoji
              2 days ago










            • @chishimotoji: a solution with only numbers from 1..25 after lunch ...
              – Herbert
              2 days ago






            • 1




              usepackage{xcolor} for defining a color series
              – Herbert
              yesterday


















            • What is the syntax random in your answer?
              – chishimotoji
              2 days ago






            • 1




              pscalculate{randint(1,25)} get an integer random between 1 and 25
              – Herbert
              2 days ago










            • Ohh, I see. Thanks.
              – chishimotoji
              2 days ago










            • @chishimotoji: a solution with only numbers from 1..25 after lunch ...
              – Herbert
              2 days ago






            • 1




              usepackage{xcolor} for defining a color series
              – Herbert
              yesterday
















            What is the syntax random in your answer?
            – chishimotoji
            2 days ago




            What is the syntax random in your answer?
            – chishimotoji
            2 days ago




            1




            1




            pscalculate{randint(1,25)} get an integer random between 1 and 25
            – Herbert
            2 days ago




            pscalculate{randint(1,25)} get an integer random between 1 and 25
            – Herbert
            2 days ago












            Ohh, I see. Thanks.
            – chishimotoji
            2 days ago




            Ohh, I see. Thanks.
            – chishimotoji
            2 days ago












            @chishimotoji: a solution with only numbers from 1..25 after lunch ...
            – Herbert
            2 days ago




            @chishimotoji: a solution with only numbers from 1..25 after lunch ...
            – Herbert
            2 days ago




            1




            1




            usepackage{xcolor} for defining a color series
            – Herbert
            yesterday




            usepackage{xcolor} for defining a color series
            – Herbert
            yesterday










            up vote
            2
            down vote













            A pure PSTricks solution is also possible but we should not reinvent the wheel.



            documentclass[12pt,pstricks,border=1pt]{standalone}
            usepackage{tikz,xstring}
            usetikzlibrary{calc}
            defn{5}defmylist{}

            pgfmathsetmacro{numbermax}{n*n}
            foreach x in {1,...,numbermax}{
            xdefmylist{mylistnoexpand{xnoexpand}}
            }
            pgfmathsetmacro{nt}{n-1}
            newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
            begin{document}
            large
            begin{pspicture}[showgrid](n,n)
            foreach i in {0,...,nt}
            {
            foreach j in {0,...,nt}
            { pgfmathdeclarerandomlist{mynum}{mylist}
            pgfmathrandomitem{mynum}{mynum}
            StrSubstitute{mylist}{{mynum}}{}[sublist]
            globalletmylistsublist
            pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
            pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
            definecolor{mau}{rgb}{maum,mauh,0.1}
            rput(!ispace .5 add jspace .5 add){color{mau}mynum}
            }
            }
            end{pspicture}
            end{document}


            enter image description here



            About Pseudo random generator



            Rand produces a floating point random number between 0 and 1 inclusive and rand produces a "huge" integer.



            documentclass[pstricks,border=12pt,12pt]{standalone}
            pstVerb{realtime srand}

            begin{document}
            begin{pspicture}[showgrid](6,6)
            psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
            end{pspicture}
            end{document}


            enter image description here






            share|improve this answer



























              up vote
              2
              down vote













              A pure PSTricks solution is also possible but we should not reinvent the wheel.



              documentclass[12pt,pstricks,border=1pt]{standalone}
              usepackage{tikz,xstring}
              usetikzlibrary{calc}
              defn{5}defmylist{}

              pgfmathsetmacro{numbermax}{n*n}
              foreach x in {1,...,numbermax}{
              xdefmylist{mylistnoexpand{xnoexpand}}
              }
              pgfmathsetmacro{nt}{n-1}
              newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
              begin{document}
              large
              begin{pspicture}[showgrid](n,n)
              foreach i in {0,...,nt}
              {
              foreach j in {0,...,nt}
              { pgfmathdeclarerandomlist{mynum}{mylist}
              pgfmathrandomitem{mynum}{mynum}
              StrSubstitute{mylist}{{mynum}}{}[sublist]
              globalletmylistsublist
              pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
              pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
              definecolor{mau}{rgb}{maum,mauh,0.1}
              rput(!ispace .5 add jspace .5 add){color{mau}mynum}
              }
              }
              end{pspicture}
              end{document}


              enter image description here



              About Pseudo random generator



              Rand produces a floating point random number between 0 and 1 inclusive and rand produces a "huge" integer.



              documentclass[pstricks,border=12pt,12pt]{standalone}
              pstVerb{realtime srand}

              begin{document}
              begin{pspicture}[showgrid](6,6)
              psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
              end{pspicture}
              end{document}


              enter image description here






              share|improve this answer

























                up vote
                2
                down vote










                up vote
                2
                down vote









                A pure PSTricks solution is also possible but we should not reinvent the wheel.



                documentclass[12pt,pstricks,border=1pt]{standalone}
                usepackage{tikz,xstring}
                usetikzlibrary{calc}
                defn{5}defmylist{}

                pgfmathsetmacro{numbermax}{n*n}
                foreach x in {1,...,numbermax}{
                xdefmylist{mylistnoexpand{xnoexpand}}
                }
                pgfmathsetmacro{nt}{n-1}
                newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
                begin{document}
                large
                begin{pspicture}[showgrid](n,n)
                foreach i in {0,...,nt}
                {
                foreach j in {0,...,nt}
                { pgfmathdeclarerandomlist{mynum}{mylist}
                pgfmathrandomitem{mynum}{mynum}
                StrSubstitute{mylist}{{mynum}}{}[sublist]
                globalletmylistsublist
                pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
                pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
                definecolor{mau}{rgb}{maum,mauh,0.1}
                rput(!ispace .5 add jspace .5 add){color{mau}mynum}
                }
                }
                end{pspicture}
                end{document}


                enter image description here



                About Pseudo random generator



                Rand produces a floating point random number between 0 and 1 inclusive and rand produces a "huge" integer.



                documentclass[pstricks,border=12pt,12pt]{standalone}
                pstVerb{realtime srand}

                begin{document}
                begin{pspicture}[showgrid](6,6)
                psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
                end{pspicture}
                end{document}


                enter image description here






                share|improve this answer














                A pure PSTricks solution is also possible but we should not reinvent the wheel.



                documentclass[12pt,pstricks,border=1pt]{standalone}
                usepackage{tikz,xstring}
                usetikzlibrary{calc}
                defn{5}defmylist{}

                pgfmathsetmacro{numbermax}{n*n}
                foreach x in {1,...,numbermax}{
                xdefmylist{mylistnoexpand{xnoexpand}}
                }
                pgfmathsetmacro{nt}{n-1}
                newpsstyle{gridstyle}{griddots=0,subgriddiv=1}
                begin{document}
                large
                begin{pspicture}[showgrid](n,n)
                foreach i in {0,...,nt}
                {
                foreach j in {0,...,nt}
                { pgfmathdeclarerandomlist{mynum}{mylist}
                pgfmathrandomitem{mynum}{mynum}
                StrSubstitute{mylist}{{mynum}}{}[sublist]
                globalletmylistsublist
                pgfmathparse{0.9*rnd+0.3} pgfmathsetmacro{maum}{pgfmathresult}
                pgfmathparse{0.8*rnd} pgfmathsetmacro{mauh}{pgfmathresult}
                definecolor{mau}{rgb}{maum,mauh,0.1}
                rput(!ispace .5 add jspace .5 add){color{mau}mynum}
                }
                }
                end{pspicture}
                end{document}


                enter image description here



                About Pseudo random generator



                Rand produces a floating point random number between 0 and 1 inclusive and rand produces a "huge" integer.



                documentclass[pstricks,border=12pt,12pt]{standalone}
                pstVerb{realtime srand}

                begin{document}
                begin{pspicture}[showgrid](6,6)
                psLoop{5}{qdisk(!Rand 6 mul Rand 6 mul){!Rand 4 div}}
                end{pspicture}
                end{document}


                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 2 days ago

























                answered 2 days ago









                Artificial Stupidity

                5,08811039




                5,08811039






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464486%2fhow-to-create-the-random-numbers-with-pstricks%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks