Questions tagged [random-numbers]

about the production of document elements involving the creation of random numbers. Affiliated tags could be {tikz-pgf}, {tables}, {letter}, {fonts}.

Filter by
Sorted by
Tagged with
1 vote
1 answer
19 views

How to stop Beamer \only overlay regenerating random parameters on parts of frame previously rendered

I have some lcg randomisation in a frame that uses \only. My problem is that the multiple PDF pages that are supposed to make the parts of the frame look like they are slowly appearing next to what ...
user avatar
0 votes
2 answers
78 views

specify a range using random numbers

I am using the following code to illustrate double angle theorem and although it works some of the time, I world like a method to define the random numbers so it always takes the form, as shown in the ...
user avatar
  • 115
0 votes
0 answers
102 views

Worksheet generator with random numbers

I would like to implement a worksheet generator in Latex with the following features: It should contain commands to generate addition, subtraction, multiplication and division exercises with random ...
user avatar
1 vote
1 answer
80 views

How to set specific seed for random number generator in expl3 for use with xfp

I am using the xfp package to generate some random numbers, and am trying to figure out how to specify a specific random seed for the pseudo random number generator (so it gives the same results ...
user avatar
  • 115
4 votes
2 answers
189 views

Evaluating expressions using xfp

I want to generate two integer random numbers for the radius (r) and heigth (h) of a cilinder, in a certain question of my exam. I am using the package xfp to generate the random numbers. However, I ...
user avatar
3 votes
3 answers
241 views

Can a PDFLaTeX file contain a random number based on the end user?

Suppose I want to design a math exam to be posted as a single PDF file, for example one asking students to solve $ax^2+bx+c=0$. But I want each student who gets the PDF file to see a different set of $...
user avatar
  • 8,495
3 votes
1 answer
216 views

Random seed each compilation in XeLaTeX

I've found two answers for ``How to get a new PGF seed each compilation?'' 1 2, and they work wonderfully on PdfLaTeX. However, neither of the methods work on XeLaTeX. I get the error ! Undefined ...
user avatar
  • 59
0 votes
2 answers
94 views

Plot a random parabola via standard form and rewrite in expanded form

I have another question in regards to using expl3. I am trying to generate a random parabola and then print a rewritten form of that generated equation. I have a \NewDocumentCommand named \parabola. I ...
user avatar
  • 155
4 votes
1 answer
144 views

Sorting a list of randomly generated numbers

This is a part two of a question I asked a few days ago and was answered rather spectacularly by user egreg, which you can find here. I'm now looking to take part of the LaTeX provided to me, and ...
user avatar
  • 155
1 vote
4 answers
172 views

Using an alias / variable as an input for a newcommand

I am currently trying to set up a conditional statement that takes a randomly assigned integer, and provides a specific output depending on if the integer is odd or even. I've written this so far \...
user avatar
  • 155
1 vote
1 answer
49 views

Randomly order document content at view-time

In economics, author order is traditionally alphabetical. Due to the known bias induced by this ordering, there is small movement to randomly order a paper's authors (example). I can order document ...
user avatar
  • 449
3 votes
2 answers
130 views

Random numbers and if statements

I want to produce a random number and with this check an if statement. But it does not work. I tried the following: \documentclass{minimal} \usepackage[first=0, last=1]{lcg} \newcommand{\random}{\rand\...
user avatar
  • 31
1 vote
2 answers
95 views

Obtain a table of non-uniformly-distributed random 0 and 1 draws

I wish to produce a n x m matrix of randomly-drawn 0s and 1s, in which draws are fresh with each compilation. So far, I have achieved this with the following code for a 15 x 10 table. However, 0s and ...
user avatar
2 votes
1 answer
89 views

Setting variables to random numbers for pgfplots

In the declare function scope, I am trying to set randomized numbers to variables, as shown in the code: \documentclass[12pt]{article} \usepackage{pgfplots} \usepackage{float} \pgfplotsset{compat=1.17}...
user avatar
  • 1,437
0 votes
1 answer
472 views

Fresh Numbering for theorems and Lemma in new chapter [duplicate]

I am building a report document. I want to start the numbering of lemmas and theorem with 1 in every new chapter. For example, I have 3 Lemmas and 2 theorems in Chapter number 1. Now, in chapter 2 I ...
user avatar
  • 107
1 vote
1 answer
150 views

Saving Random Numbers in xsim for Solutions

I'm trying to create exercise sheets with random numbers and xsim. Each time I generate random numbers, though, the variables are overwritten to create new exercises (desired), but also overwritten so ...
user avatar
3 votes
1 answer
88 views

TikZ: "escaping" random path

On page 1024 of the PGF manual there is a small code to draw random paths which are "contained", or which don't escape too far from their starting points. I copied part of the code to draw that sort ...
user avatar
  • 1,359
0 votes
1 answer
61 views

How do random numbers in expl3 Syntax work?

This is a follow-up to a prior question of mine. The same device is used in a number of other randomness-related questions here though. What exactly is the source of (pseudo)randomness when writing ...
user avatar
  • 2,253
3 votes
2 answers
369 views

Tikz: Randomly drop connections in neural network

I used Tikz to draw a full connected neural network. Now I would like to drop randomly a certain proportion of arrows. How can I do that and is it possible to use my code for that? Here is my code and ...
user avatar
  • 1,135
1 vote
2 answers
53 views

Random number generator for case distinctions

I would like to compile a snippet of code using a random case distinction. How can I implement that? No-LaTeX pseudocode: x = rand(1,4) // random number between 1 and 4 if( x == 1 ) Let us talk ...
user avatar
  • 2,253
7 votes
2 answers
308 views

Modeling randomly generated inscribed triangles

The problem I am modeling: Three points are randomly chosen on a circle. What is the probability that the triangle formed by these three points contains the center of the circle? Conceptual ...
user avatar
7 votes
2 answers
279 views

How to pass multiple random numbers (generated using lcg package) to a macro?

Inspired from this answer I would like to generate a multi-digit addend using some random numbers. I can generate the random numbers, but I'm unable to use them properly (Tex capacity exceeded). Here ...
user avatar
  • 1,109
0 votes
1 answer
84 views

Number section-LaTex

How Can I change the format number section, subsection, and subsubsection? The document put: Section (I.) Subsection (I.1) Subsubsection (I.1.1) But... I want: Section (I.) Subsection (1.1) ...
user avatar
3 votes
2 answers
481 views

How can I assign unique numbers, or a sequence, in LaTeX?

I'm trying to make flashcards to export to Anki, a flashcard program. I'm using the following link: http://reh.math.uni-duesseldorf.de/~zibrowius/LatexNoteImporter/ I'd like to assign each card with ...
user avatar
2 votes
2 answers
88 views

switch string/commands based on "random" values to produce random cards

Update Or is there a way to generate random number between 1 and 52 using lcg package, then associate it to one of the 52 cards from the pst-poker package. Which might be easier to achieve? OP ...
user avatar
  • 515
2 votes
2 answers
139 views

tabular environment with random positions

I would like to simulate a simple random cloud of letters using a custom tabular environment, like this: \documentclass{article} \usepackage{lcg} \begin{document} \reinitrand[first=12,last=20,...
user avatar
  • 828
7 votes
4 answers
4k views

How to get a random number within a range?

How can I return a random number within a range? Here is a minimal (non-)working example of what I'm after: \documentclass{article} \newcommand{\thecmd}[1]{ % todo, set a to: #1-(#1/4) % todo, set ...
user avatar
1 vote
2 answers
498 views

How to create a subtraction worksheet with random numbers in each question?

I would like to create a worksheet which looks like the following: Here instead of manually typing every question, I would like to create random questions, where the subtrahend is from a set of ...
user avatar
  • 784
1 vote
0 answers
74 views

randomizer/anti-cheating question generator [duplicate]

It is a rather common practice that teachers prepare multiple versions of a test for the same exam in order to reduce cheating. Can \LaTeX do this? I want to design a math test with a set of ...
user avatar
  • 8,495
1 vote
0 answers
195 views

creating random question paper using probsoln package

I have written code for generating random questions using Probson package. The only problem I face is that It shows the same output again and again when I run the Program. What I want is whenver I ...
user avatar
1 vote
1 answer
86 views

Evenly distributed random non-stops

I am trying again to recreate some strange images. I am trying to generate hexagons of nonstop with three colors. The distribution of these three should be Color 1 = (N-1)^2 Color 2 = (N-1)*N Color 3 ...
user avatar
2 votes
2 answers
167 views

How to randomize entries of a table?

Consider the following code. Is such a randomization possible? I have many different tables where the number of letters may vary from table to table. However, within each table, the letters correspond ...
user avatar
  • 273
4 votes
1 answer
635 views

Random Numbers and Variables in Latex

Below is my MWE. I understand the gist of tikz and foreachs, but when it comes to variables I don't understand most yet. I want an arrow pointing from each cell to a module, and them from the module ...
user avatar
  • 225
3 votes
2 answers
308 views

Add a randomly generated number to a latex document to discourage cheating on an exam

I am trying to cut down on a particular kind of cheating during my in-class exams. What some students are doing is taking pictures of the exam (while I am looking somewhere else), and uploading them ...
user avatar
18 votes
2 answers
2k views

Drawing a constant randomly distorted circle

I am trying to draw a special and contradictive plot : A circle with random distortions which have to remain constant regardless of how many times I build the document. An example of what I am trying ...
user avatar
  • 11.9k
2 votes
2 answers
557 views

How can I duplicate a random number in two places on the same page in a latex editor?

I am trying to create a mental math practice sheet generator in a latex editor. For the number of questions intended, I require only half of A4 sheet. So the other half I want to print the same set of ...
user avatar
  • 21
2 votes
1 answer
353 views

Least common multiple of many numbers

I need to make visualization like this: In this case we have 3 numbers I need to make it with 2 or 3. It will be very good if it looks like this - here we have denominating only 1 number. \...
user avatar
1 vote
0 answers
85 views

"Esami" package: random extraction from a set of elements?

I am trying to give randomness to a test with the "esami" package and the command "randestrai" was promising. I wanted to pick some random prime numbers so I wrote \randestrai{3,5,7,11}{alpha} which ...
user avatar
4 votes
1 answer
2k views

Tikz picture using random number

I am using currently tikz to describe a law used in a Theory. This method describes the construction of sub-Area by breaking point in different lines. I want to reproduce this picture: In this one, ...
user avatar
  • 139
9 votes
1 answer
695 views

Random points in a rectangle

I have made a graph as shown in the following figure: For each rectangle I'd like to generate n random points in it, is it possible? My code: \begin{tikzpicture} \begin{axis}[ grid=major, ...
user avatar
1 vote
2 answers
531 views

Help with writing base 10 addition/subtraction formula

I am preparing this small tutorial for addition and subtraction formulas for kids who have a strong understanding of base-10 representation and also have a good enough understanding of addition and ...
user avatar
  • 21
4 votes
1 answer
160 views

\lipsum redefinition doesn't expand well with lcg random integer

I'd like to redefine the \lipsum command provided by the lipsum package such that \lipsum{} outputs not a predefined amount of lorem ipsum paragraphs, but a single, random, lorem ipsum paragraph (that ...
user avatar
4 votes
1 answer
730 views

3.33333pt at the top of the document

I am currently attempting to write my first Latex document and having some issues with it. There is a weird 3.33333pt at the top of the document, as can be seen in the attached image, and it will not ...
user avatar
1 vote
0 answers
151 views

Creating Brownian Motion graph and labeling dW

I've found code to create the Brownian motion graph - \newcommand{\Emmett}[5]{% points, advance, rand factor, options, end label \draw[#4] (0,0) \foreach \x in {1,...,#1} { -- ++(#2,rand*#3) } ...
user avatar
2 votes
2 answers
77 views

PGF macro to map value to a different interval

I'm trying to write a macro to be used with random generators (in particular rnd) within Tikz, to map numbers to different intervals. [0, 1] ---> [a, b] f(x) = x*(b-a) + a What I tried so far is:...
user avatar
  • 211
3 votes
1 answer
999 views

PGF/Tikz: Random seed set to same number, getting different outputs in different contexts

I am trying to create a random walk (as a substitute for a true Brownian motion) which starts and ends at 0. I generate the random walk using random numbers for each step, and the standard way of ...
user avatar
0 votes
2 answers
681 views

How to generate an unique hexadecimal hash from a string?

Is it possible to generate a unique hexadecimal hash from a string in LaTeX? It does not have to be cryptographic, so it doesn't matter if it is reversible. For example: input: 2018013001 output: ...
user avatar
  • 1,436
2 votes
0 answers
189 views

Calling pgf rand inside pgfmathsetmacro creates extra text

I am using pgf and tikz for some latex questions. The code below illustrates a problem I am facing: when I use the rand function from pgf inside a pgfmathsetmacro I get some extra text at the ...
user avatar
  • 315
3 votes
1 answer
559 views

PGF Dimension too large

I am trying to create mental math worksheets that extend math facts from 6*7=___ to something like 6*700000=_________. Apparently, though PGF and/or TeX cannot handle numbers bigger than around ...
user avatar
3 votes
1 answer
392 views

Why Are My Random List Items Always Identical? [duplicate]

I have a list and then two randomly selected items from them. But those two items are always the same. Why? \documentclass{article} \usepackage{pgf} \usepackage{pgffor} \pgfmathsetseed{\number\...
user avatar