Questions tagged [random-sampling]
For questions about generating random samples from some sample space (e.g. numbers, strings, matrices).
34
questions
1
vote
1
answer
103
views
How to plot random points in 3 dimensions in order to calculate volume of a torus through Monte Carlo integration
I am new to Monte Carlo integration and have been tasked with using MC integration in order to calculate the volume of a torus with inner radius 5cm and outer radius 10cm. Below is the code I have ...
0
votes
1
answer
41
views
Grid walk vs. uniform random weights for bounded grid
I want to sample from a bounded space, say $[0,1] \times [0,1] \in \mathbb{R}^2$.
I have read about a so-called grid walk that fixes a starting point $x_0 = (x_{0,1}, x_{0,2})$ and then proceeds via $...
5
votes
1
answer
206
views
How to optimize an approximated matrix multiplication?
[UPDATING]
The old one is a simplified version of the current one. Here is a solution based on the answer proposed by professor Bangerth down below. To describe what I am trying to do, first rewrite ...
0
votes
0
answers
56
views
generating multivariate Gaussian samples with constraints
Using GRFs, one generates samples $x \sim N(m,K)$ with arbitrary mean $m$ and covariance matrix $K$ using a scalar Gaussian generator as
$x = m + Lu$,
where $L$ is a lower triangular matrix, such that ...
1
vote
0
answers
38
views
Sampling points from space based on known density
I have a problem where I heavily need to restrict the number of points at which I sample a function based on the values of a different function.
I have two functions:
$f:{\mathbb{R}\times [0,\infty)\...
3
votes
0
answers
48
views
Does an alias method exist for sampling a discrete distribution that is slighlty modified at each iteration?
I have the following problem. I must sample from a discrete distribution that is changing at each sort.
Let me explain, with a "vivid" description, I draw a color ball from a bag. The ...
1
vote
1
answer
127
views
How to sample points uniformly over a region of the unit sphere
I am looking for a way to sample points uniformly around a particular point on the unit sphere.
Working on spherical coordinates we can express any point on the unit sphere as $(\sin\theta \cos\phi, \...
5
votes
0
answers
90
views
Is this a legit way to sample a random matrix spectrum?
In order to undergird a theoretical model concerning many body physics, I want to have exponentially large eigenvalue spectra from the random matrix GOE ensemble. its properties are mainly
(i) a ...
1
vote
3
answers
567
views
Optimization on MCMC codes
I am looking for MCMC codes with a GPU suport (like NVIDIA or OpenCL libraries) to make faster run chains.
If someone could have a state of the art ...
2
votes
1
answer
99
views
Changing randomly a unit vector
For studying a spin model on a lattice, I have to generate a random unit vector starting from a pre-exstisting one. There are multiple ways to do it, but the book I use suggests generating a random ...
0
votes
0
answers
119
views
Algorithm for Gaussian random field generation via Karhnunen--Loeve expansion
I have difficulty understanding how to generate a Gaussian random field from Karhunen--Loeve expansion.
Precisely, I need to generate a zero-mean field with covariance function $C(x, y)$. We find ...
0
votes
2
answers
248
views
Different questions about "Inverse Physics problems"
I am in a context of forecasts in astrophysics. Don't be too rude if questions seem to you stupid or naive but rather indulgent, I am just looking for better undertsand all these numerical methods of ...
1
vote
0
answers
32
views
Name of method for quickly sampling many small-probability booleans
I have a list of probabilities $p_k$, each corresponding to a Bernoulli distribution. These values of $p_k$ are all small (let's say 0.1% or less). I want to prepare a data structure that allows ...
2
votes
3
answers
973
views
Generating Random Orthogonal Matrices in C++
I'm looking for an open-source library for the generation of random n-dimensional orthogonal matrices in C++.
In python, it looks like such a function is available in the NumPy package. But I was not ...
1
vote
1
answer
42
views
How is the D value being updated at simple RRT algorithm?
I am studying the following lecture (image) regarding 5 iterations of the simple RRT algorithm.
I am trying to understand how each value is being updated regarding each iteration. I have figured out ...
0
votes
1
answer
135
views
Monte Carlo - Random Walk Simulation - polyfit the log log data points?
This is part of the code in matlab for a random-walk simulation.
To test the code, I'm using steps=[30]; there will be more values, but I want to run it for 1 trial to decrease code processing.
<...
1
vote
1
answer
68
views
Is there a better way to do run time analysis than this?
I currently have 2 different functions with options to vectorise them: acc_rej_sine(max_iter, algorithm=None) and ...
2
votes
0
answers
34
views
Randomized Submatrix of a Sparse Matrix
I have a sparse square matrix $A$ with size $n \times n$ and number of nonzero entries $nnz$.
The goal is making a sub-matrix $B$ with $s$ nonzeros which are randomly chosen from $A$. Duplicates are ...
1
vote
2
answers
3k
views
Uniform dots distribution in a sphere
I'm trying to implement Barnes-Hut algorithm, with a binary tree. My initial conditions are a uniform mass distribution in a sphere with radius $R$. How can I create uniform dots distribution in a ...
0
votes
1
answer
116
views
Sampling simulation steps logarithmically
The common case of for instance a Monte Carlo simulation is, if we want to run our simulation for $N$ steps, we define a delta $\Delta,$ such that $N/\Delta = n$ tells us the frequency with which we ...
3
votes
1
answer
67
views
Testing Wiener process splitting in adaptive-step SDE integrators
I am investigating various methods for adaptive-step integration of stochastic differential equations and trying to implement them. All of the papers that I've seen (e.g. H. Lamba, J. Comp. App. Math. ...
5
votes
4
answers
2k
views
Rotate a vector by a randomly oriented angle
We start off with a unit vector $\mathbf{v}$ randomly oriented in 3D space and we want to generate another unit vector $\mathbf{w}$ so that
$$ \mathbf{w}\cdot \mathbf{v} = \cos \beta $$
where $\beta$...
10
votes
2
answers
2k
views
Estimate information entropy through Monte Carlo sampling
I am looking for methods that allow estimating the information entropy of a distribution when the only practical ways of sampling from that distribution are Monte Carlo methods.
My problem is not ...
3
votes
1
answer
164
views
Why are Hamiltonian dynamics used in MCMC?
In Hamiltonian Monte Carlo, Hamiltonian dynamics are used to generate new proposals from the current state. I understand why these dynamics are used as opposed to random walk behavior to generate ...
1
vote
1
answer
62
views
Finding optimal point distance to get desired number of random points in an area
I have a random point generator which takes a distance $d$ and fills an area with points such that distance between any two points is no less that $d$:
I need to control the number of points in the ...
0
votes
2
answers
58
views
How to choose a good distribution for visualizing phase changes in the nature of the roots of a quadratic equation
I'm not sure if this SE site is the best one for this question, so let me know where it should be moved to if you think it doesn't belong here.
After learning about the quadratic formula, I'm ...
2
votes
1
answer
766
views
(numpy/scipy) Build a random vector given mean vector and covariance matrix
After running several calculations with numpy, I end with the mean vector and covariance matrix for a state vector. Is there a way with numpy or scipy to sample a random vector around this mean and ...
2
votes
1
answer
68
views
Sampling vector so they will have a given euclidean distances matrix
Given a matrix $M\in\mathbb{R}^{P\times P}$ , is it possible to sample $P$ vectors $u_i\in\mathbb{R}^N$, $i=1..P$ so that $\|u_i-u_j\|=M_{ij}$.
Obviously for not any $M$ this is possible, i.e. it has ...
10
votes
3
answers
1k
views
How to sample points in hyperbolic space?
Hyperbolic space in the Poincaré upper half space model looks like ordinary $\Bbb R^n$ but with the notion of angle and distance distorted in a relatively simple way. In Euclidean space I can sample a ...
1
vote
0
answers
99
views
Monte Carlo sampling of particle system for velocity dependent potential
When sampling configurations of point particles in statistical mechanics by means of (Markov chain) Monte Carlo, we may work with a potential that only depends on the positions of the particles, and ...
3
votes
5
answers
2k
views
Algorithm for efficient weighted sampling from a collection that can efficiently be updated
I'm writing a Monte Carlo simulation in which I have to maintain a large collection of items. This collection contains a great many duplicates, and it will most likely be best to store some or all of ...
2
votes
1
answer
160
views
What is the name of the optimization algorithm that uses random sampling?
I am generating random weight as per e.g. below. The I generate a set of 3 values say 100, 250, 300 and I multiple them with the weights below
Initial population.
...
3
votes
1
answer
302
views
Random placement of euclidean points with constrained inter-point distances in a fixed area
I'd like to place as many random points as possible in a 2D square $S=[0,1]x[0,1]$ such that the euclidean distance $d$ between any two points $d$ is greater than a given value $b$ (b is small). I'm ...
4
votes
1
answer
963
views
Sampling from posterior predictive distribution
First post. I'm working on this problem using Bayesian methods. In desperation I'm considering using p-values (shock horror), specifically posterior predictive p-values. So I need to simulate from the ...