Questions tagged [random]

Questions about random number generation and the properties of numbers so generated.

Filter by
Sorted by
Tagged with
11
votes
2answers
635 views

How to generate a random integer array satisfying complex constraints

I want to generate several random arrays {x1,x2,x3,x4,x5} that satisfy the following complex constraints: ...
0
votes
0answers
41 views

How to add a number, say, 1 to a random real number in Mathematica? [duplicate]

I wish to add, say, 1 to a random real number, say between 1/3 and 1/6. I have used the following code in Mathematica, but it does not answer properly. code: p := RandomReal[1/6,1/3] q:=p+1 p ...
7
votes
3answers
112 views

Specifying range in RandomReal

Is it possible to define the specific range of a RandomReal array for each coordinate? For example, the code ...
11
votes
4answers
323 views

What is the optimal way to create a recombined version of two lists?

I would like to randomly recombine two lists of the following form: l1 = {a,b,c,d,e,f} l2 = {1,2,3,4,5,6} Where their recombination is similar to that of DNA, so ...
2
votes
0answers
69 views

Random Number Generation using LogNormalDistribution

I have a problem that I can't seem to figure out on my own due to limited knowledge of mathematics, and I was hoping I could seek help from the community. I would like to use ...
0
votes
1answer
61 views

Problem with iterations of Prepend/While

I am doing some work with black-scholes and am trying to find random interest rates based on some given information. This is my original code: ...
6
votes
4answers
355 views

How can I generate random matrices with certain requirements for the entries?

I would like to generate random 9x9 matrices, which contain only the digits 1-9, each one appearing exactly ...
2
votes
1answer
100 views

How to put a loop in a loop

I am doing some work with black-scholes. As commented within my code, I need my while loop to run 100 times. I am not sure if the best way to do this is with a nested argument or placing a for loop or ...
1
vote
1answer
29 views

Quickly generate random text

I am writing some tests and would like to introduce large chunks of random alphabetic text (just characters a-z) to the input. The way I am generating the text now is like this: ...
7
votes
2answers
220 views

Randomly generated coordinates

I want to code that will do the following: Write a Mathematica function called randomHop that takes as its argument a list containing two coordinates x and y; ...
-1
votes
3answers
249 views

How can I generate monotonic random real numbers

My question is simple, and therefore I made a search of an answer to it using the Repository of this forum. There are relevant questions, however, none of them answers to the following question. My ...
1
vote
0answers
42 views

Sampling pairs of nodes with given distance between them

For the purposes of this question we assume undirected and connected graphs. I am trying to learn how to efficiently find pairs of nodes in a graph that are separated by prescribed distance $d.$ One ...
12
votes
4answers
2k views

Is there a way to randomly distribute points within a circle on the surface of a sphere?

I'm attempting to set up a situation where on a 3D sphere, I choose a random point and construct a circle around this point with some radius. I then want to randomly distribute points within this ...
0
votes
1answer
66 views

Generating random numbers from specified distribution under a constraint

I need to generate 500 numbers from a distribution specified. I used the well-known CDF method, but since I'm new to Mathematica, I don't know how to set a condition on the sum of these variables. <...
4
votes
2answers
70 views

Create a $N\times N$ random matrix with correlated off-diagonal elements

I am working on spectral distribution of random matrices. I need to use simulations and I have been switching between MATLAB and Mathematica. I wish to perform all my computations on Mathematica. In ...
0
votes
0answers
50 views

One Function of Two Random Variable

I wonder how to implement below derivation in wolfram mathematica. I want to see integrate results like below picture. Can you help. I used "TransformedDistribution" but it shows only distribution ...
1
vote
0answers
25 views

What does this statement about congruential randomness mean in the documentation?

Reading through the random number generator guide on wolfram, under the methods section for the congruential method, it talks about the “Bits” option. Could someone explain what this means to me? I ...
0
votes
2answers
75 views

How to generated random waves

I want to generate a set of $N$ random waves, where the wave vector and phase are random numbers, this is my code ...
2
votes
1answer
112 views

Evaluate a parametric function dependent on a random number of parameters

This is a question related to the evaluation of a parametric function dependent on a random number of parameters. Consider a "blackBox" that returns a parametric function dependent on time (t) and, ...
10
votes
3answers
1k views

Efficiently finding furthest two nodes in a graph

I am trying to learn how in an efficient way can one find the diameter of a random graph, that is, the longest shortest path, and its corresponding end-nodes. The direct built-in function ...
0
votes
0answers
24 views

Optimizing and Parallel Computing for Large Dyadic Intervals

I need help with the efficiency of my code i.e. less time so I can compute for large range of values. My function n[x] takes in a number x and outputs the ...
5
votes
4answers
227 views

Manipulate a list: replace random position of a specific integer n times by 0

I have this matrix with 3 sublists: d = {{1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0}, {0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1}, {0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0}}; For ...
6
votes
2answers
659 views

How can I shorten the calculation time effectively?

I try to do a big simulation like below. (However, I do not change the sizes I want to 10 ^ 5, 10 ^ 7, 10 ^ 9.) ...
8
votes
3answers
886 views

Better random (unique) file name

In order to avoid conflict with file names produced by some code running in multiple instances of Mathematica I append the date and a random string at the end hoping to create a unique filename. The ...
1
vote
2answers
45 views

Question About Sampling from Conditional Distribution Created from Approximated Distribution

First, set the data and prepare the conditional distribution. pxy is joint distribution of Random Variable x and...
6
votes
4answers
851 views

RandomInteger with equal number of 1 and -1

I want to generate a list of random integers with only three values 1,0,-1. I know it can be done through RandomInteger[{-1, 1}, n]. How can I impose constraint on this list so that every integers in ...
4
votes
5answers
166 views

Generate random non-zero “island” in matrix of zeros

I'm trying to write a code which will generate a 3 dimensional array of 0s, then pick some random location in the array, and subsequently expand contiguously to random neighboring sites until a set of ...
3
votes
1answer
57 views

How to get a list of all known classes?

I'd like a function that returns a stringified entity at random. I can't seem to find a full list of classes from which to sample:
9
votes
5answers
1k views

How to generate random points without duplication?

In generating a list of random 2D integral coordinates e.g. {{u1,v1}, {u2,v2}, {u3,v3},...}, how can one write a condition specifying that no point is repeated, i.e ...
2
votes
1answer
29 views

Help with evaluation of the differential of a BSplineFunction?

It can be useful to generate a smooth random function over $[-L,L]$ with BSplineFunction: ...
5
votes
1answer
49 views

RandomPoint returns compiler errors on RegionIntersection of two Meshs?

Consider the intersection of two ConvexHullMesh's, m1 and m2. ...
3
votes
0answers
91 views

Parallel evaluation of RandomVariate for an InterpolatingFunction

I need to generate a lot of point according to a given distribution. I don't have an analytic form of this distribution so I am using an InterpolatingFunction of ~100 points computed numerically. I ...
6
votes
3answers
543 views

Generating random, non-repeating points on the plane

The problem is to generate random points on the plane that are unique (i.e. no repetition of a point). The following won't work because of repetition: ...
3
votes
0answers
67 views

Why does SeedRandom with same seed used twice produce such different results?

I have occasionally used RandomSeed[100] twice in the code and noticed behaviour that I don't understand. Consider: ...
7
votes
2answers
357 views

How can I generate a sin wave with power law noise?

I am interested in simulating a signal with different types of power law noise, as entitled in wikipedia, "Color of Noise". (The audio examples are pretty cool). Basically, white noise, which many ...
1
vote
0answers
110 views

RandomVariate with ProbabilityDistribution performs well in 10.0, but not in later versions

I have a custom probability distribution function and I want to generate numbers according to this PDF. Interestingly enough, this works without trouble on my MacBook with Mathematica 10.0, but when I ...
1
vote
1answer
92 views

Random sampling of a discrete distribution in NetGraph

Within a NetGraph I would like to use the output of a softmax layer, interpreted as a probability distribution, to sample a "next token". Since this is done inside an RNN structure, I cannot do this ...
4
votes
1answer
89 views

Improving Speed of Binomial and Multinomial Random Draws

A number of users have discussed the speed of Random number generation in Mathematica. The Binomial and Multinomial random number generators in Mathematica are fast if multiple draws are needed for ...
2
votes
1answer
140 views

Generate a uniform distribution over an $n$-simplex employing quasi-random low-discrepancy points

This post is intended in a similar direction to an earlier one Can I use Compile to speed up InverseCDF? . I now wish to generate uniform points in an $n$-simplex (specifically $n=8$), making use of ...
2
votes
1answer
88 views

RandomReal in combination with NormalDistribution [closed]

I am normally not working with Mathematica, but I have to understand a code written in i! Can some body say what the arguments and parameters of code below say? ...
1
vote
1answer
48 views

Parametric Ito Process

Is it possible to make a parametric ItoProcess ? I'd like to write that equation : ...
1
vote
1answer
44 views

Ito Process with Piecewise

I have the following ItoProcess : ...
0
votes
0answers
29 views

Computing the same stochastic ODE many times but with different random seeds

I have this stochastic ODE, where I'm using ParametricNDSolve and WhenEvents : ...
2
votes
0answers
91 views

Noise covariance matrix

I am trying to find the noise covariance matrix of a random vector $\mathbf{x}$ with itself. The elements of this vector represent image pixels and are treated as random variables i.e, $\mathbf{x}=\{...
1
vote
1answer
76 views

Drawing from InverseWishartMatrixDistribution. A machine precision error?

I'm drawing from the Inverse-Wishart Distribution, but I got the following error message: ...
1
vote
2answers
100 views

Multiple unique random samples?

I'm trying to produce $n$ random samples from a list, but not all samples, and I'd like the samples to not repeat in the same execution of the command. If I'm not mistaken, something like ...
4
votes
5answers
569 views

How to generate binary array whose elements with values 1 are randomly drawn

I am trying to generate a binary matrix (whose elements are 0 or 1) of dimension 20x20. To do this, I want to supply as input the number of matrix elements that will take value 1. After, I want to ...
0
votes
1answer
78 views

Autocorrelated random field generation

Problem is related with my other question So, generate exponentially correlated row $𝑥_{0,0},𝑥_{1,0}...𝑥_{𝑛,0}$ and starting from 𝑥0,0 there will be a correlated column $𝑥_{0,1},𝑥_{0,2}...𝑥_{...
6
votes
3answers
365 views

Finding the dangling free part of a cluster connecting two nodes

I am trying to learn how to use Mathematica for analyzing graphs, more specifically in the context of connectivity and percolation. For the sample graph that I have included in this post, we have a ...
6
votes
2answers
499 views

Graphing random points on the XY-plane

I am trying to generate around 10-20 points on the xy- plane in the domain $[-10,10]\times[-10,10]$ (in 3D) and I am having trouble. I want to draw the plane in 3D, graph the random (they do not have ...

1 2 3 4 5 14