Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Generate a pseudorandom Dyck word
ResourceFunction["RandomDyckWord"][n] gives a pseudorandom Dyck word with n bracket pairs. | |
ResourceFunction["RandomDyckWord"][n,k] gives k pseudorandom Dyck words with n bracket pairs. |
Generate a pseudorandom Dyck word of length 2×10:
In[1]:= | ![]() |
Out[1]= | ![]() |
Generate 10 pseudorandom Dyck words of length 2×5:
In[2]:= | ![]() |
Out[2]= | ![]() |
Generate and plot a random Dyck path:
In[3]:= | ![]() |
Out[3]= | ![]() |
Construct a binary tree from a random Dyck word:
In[4]:= | ![]() |
In[5]:= | ![]() |
Out[7]= | ![]() |
Visualize the nested structure of a random Dyck word as a tree:
In[8]:= | ![]() |
Out[8]= | ![]() |
RandomDyckWord[n] is equivalent to ToString[ResourceFunction["RandomCombinator"][n+1],{""}]
In[9]:= | ![]() |
Out[9]= | ![]() |
Interpret a Dyck word as a sequence of functions to be composed with the initial argument x:
In[10]:= | ![]() |
Out[10]= | ![]() |
In[11]:= | ![]() |
Out[11]= | ![]() |
Generate and plot a set of Dyck paths that collectively traverse all possible edges in the lattice of Dyck paths of length 2n:
In[12]:= | ![]() |
Out[12]= | ![]() |
Visualize the distribution of random Dyck paths:
In[13]:= | ![]() |
Out[13]= | ![]() |
This visualization shows 1000 random Dyck paths of length 20 (10 bracket pairs), with the frequency of visits to each lattice point represented by blue disks of varying sizes. The dashed gray lines show all possible Dyck paths.
Wolfram Language 14.0 (January 2024) or above
This work is licensed under a Creative Commons Attribution 4.0 International License