Questions tagged [random]

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

Filter by
Sorted by
Tagged with
6
votes
1answer
46 views

Generate a random list that have 2 different ranges in 2 dimensions

Here is my thing. Each element in the list has its own range. {RandomReal[{0, 1}], RandomReal[{0, 2 Pi}]} This code alone can only generate a point. Is it ...
2
votes
1answer
80 views

Dynamic Update for 2D Random Walk

I have code for a random walk ...
0
votes
0answers
25 views

Correlated random variables

Assume we have a random variable $X(t)$ that changes as a function of time satisfying a correlation $\left\langle X(0) X(\tau) \right\rangle=e^{-\tau/\tau_c}$. Is Mathematica able to generate random ...
3
votes
2answers
66 views

Random Sample from Very Large Table

I'm currently trying to create some test data to check a numerical implementation against Mathematica's implementation of some functions. In order to do this, I've been generating a broad range of ...
3
votes
2answers
123 views

Adding noise to the data

I am trying to write a Kalman Filter for airplane radar tracking, so I generated testing data and now I want to add some white noise to this data. I have tried doing this, but it didn't help. So far I ...
3
votes
1answer
70 views

CURAND library import error to Mathematica/Wolfram 12.1

I used Mathematica/wolfram 12.1 IDE and installed CUDA toolkit 10.2. All installed correct. I try to use library CURAND with #include with random integer generator on CUDA, but get a error: ...
1
vote
1answer
44 views

How to get a RandomFraction in (0,M)?

The following code M= 5/10; A = ImplicitRegion[0< x < M, {x}]; RandomPoint[A] gives a random decimal $x\in(0,M)$. How can I get an exact fraction ...
2
votes
1answer
26 views

RandomPrime inside Manipulate gets evaluated multiple times

Manipulate[ m = RandomPrime[d]; {m, d}, {d, {20, 50}, SetterBar} ] Basically, I expected the code to generate a random prime m (under the upper bound d) for me ...
4
votes
1answer
124 views

RandomVariate cannot sample from a custom multivariate ProbabilityDistribution

Let us try to define 2D distribution through PDF: ...
1
vote
2answers
77 views

How to run 1000 examples of matrices

I have two functions of matrices, let say $f(A,\,B)$ and $g(A,\,B)$, where $A,\,B$ are positive semidefinite matrices. I want to check if $f(A, B)$ is greater than $g(A,\,B)$ for any $A,\,B > 0$. I ...
0
votes
1answer
16 views

Calculation time differs between segmented loops and one whole loop

I stumbled on a strange issue while simulating a large number of random values, $10^8$ to be precise. I generated the numbers at first by the following code: ...
2
votes
3answers
91 views

Compute volume of ellipsoid using Monte Carlo methods

I have following code in Mathematica: https://pastebin.com/zRB9vEx8 and I need to compute volume of ellipsoid with given parameters: $$\frac{x^2}{9} + \frac{y^2}{4} + \frac{z^2}{4} = 1$$ Can anyone ...
0
votes
0answers
21 views

Conditional Loops with Random Samples

I would like to simulate the following process: Pick a random number between 0 and 1. Choose a final time $t_f$. Evolve a (complicated) function $f[t]$ from $t=0$ with small timesteps $\delta t$ (the ...
2
votes
0answers
94 views

Finding 36 integer solutions to a set of 14 equations using various boundary conditions

What is good way to solve this system of equations? I have it run now for quite some time and it does not spit out a solution. ...
4
votes
1answer
98 views

Conditional Random Walk

I am attempting to model a physical process I'm observing in the lab with a random walk generator. I need to find a way to impose a condition such that when the random walk runs into a point in the ...
2
votes
0answers
44 views

How is a Lévy stabile process pdf normalized?

I'm interested in how to deal with α-stabile probability density functions, for example one with the Laplace image like: $ \phi(s) = s^{(\alpha-1)}*e^{-\nu s^{\alpha}} $ I can work with this ...
1
vote
1answer
30 views

Can I sample from a distribution whose parameters depend on the current iteration?

Let's say I want to sample from 100 Beta distributions, and in each successive one, the first parameter increases by 1. So given a current iteration number n, I ...
2
votes
1answer
94 views

How to create random graph with certain properties?

My question consists of two parts. How to create a random undirected connected graph s.t. the probability of the event "The degree of a vertex equals k" is equal to $\frac{k^{-\gamma }}{\zeta (\...
0
votes
3answers
60 views

create a rank 1 matrix from two vectors

I've seen the answers 1 and 2 about the transposition and creation of rank $m$ matrices. What I'd like to do is first create a random vector, which I know how to do with ...
0
votes
1answer
105 views

Sampling two integer lists of given sizes from a distribution that have equal sums

(This question emerged from discussions in this post.) Context and code sample: I am trying to figure out if there is a way to generate two $a$ and $b,$ comprised of $n_a$ and $n_b$ integers which ...
4
votes
1answer
62 views

Generating vectors with small inner products in a large vector space

I want to generate a large number $k$ of vectors of norm 1 in a $d$ dimensional vector space such that $k>d$. I want these vectors to have inner products as small as possible. A crude way is to ...
0
votes
0answers
27 views

Simulation of a compound renewal process with copula dependency

I'm new to Mathematica and this is brief about my project that I would like to seek advice from this group about my coding. My project is to perform 100 simulations with 1000 iteration each based on ...
6
votes
0answers
240 views

Making cool animations of an accretion disk/planetary disk

I am trying to make an animation of an accretion disk or a planetary disk. For example, a cool disk showing below (created by NAHKS TR'EHNL): or in this link Here is what I have tried so far: step1:...
2
votes
1answer
114 views

Generating random vectors using Mathematica and an inequality

Consider $n$-dimensional vectors $c^i = \left(c^i_1, c^i_2 ...c^i_n \right)$ , whose entries are complex and generated at random. These vectors are normalized such that $$|c^i|^2 = 1.$$ Using ...
11
votes
2answers
662 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
44 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
132 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
328 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
73 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 ...
9
votes
1answer
301 views

How can I solve a nonlinear equation using a Monte Carlo method?

I know FindRoot can solve nonlinear equations, but now I'm interested in solving such an equation using a Monte Carlo method. Can somebody show how that could be ...
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
358 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
107 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 ...
3
votes
2answers
67 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
227 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; ...
0
votes
3answers
285 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 ...
2
votes
1answer
61 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 ...
13
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
77 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
88 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 ...
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
100 views

How to generate 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
123 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, ...
9
votes
3answers
2k 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
245 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
662 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
935 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
50 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
858 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 ...

1
2 3 4 5
14