Skip to main content

Questions tagged [random-sampling]

For questions about generating random samples from some sample space (e.g. numbers, strings, matrices).

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

Sampling from a very high dimensional Gaussian with covariance in block form

I'm interested in sampling from a Gaussian with zero-mean and covariance given by: $$ \Sigma = \begin{bmatrix} \Sigma_{11} & \Sigma_{12} & \cdots &\Sigma_{1,100}\\ \Sigma_{21} & \...
WeakLearner's user avatar
0 votes
0 answers
37 views

Efficient sum of distributions (mixture distribution) and sampling

I manage to implement adaptive sampling by drawing samples iteratively from an update distribution which is represented by a mixture of two distributions, such that $$ρ_{new} = a * ρ_{old} + (1 - a) * ...
Zuba Tupaki's user avatar
2 votes
0 answers
95 views

What is the point in non-intrusive Polynomial Chaos output moments?

So I recently learned about Polynomial Chaos Expansion (aka PCE), and it seemed to me that its purpose was to propagate uncertainty from the inputs to the outputs more efficiently (via closed-form ...
profPlum's user avatar
  • 149
1 vote
1 answer
74 views

Random access (quasi-?)random sequence

Fix a dimension $d \ge 1$. Is there an efficiently computable sequence $f : \mathbb{N} \to [0,1]^d$ such that $f$ is either random or quasirandom (e.g., similar to Sobol sequences). Given $n \in \...
Geoffrey Irving's user avatar
1 vote
1 answer
109 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 ...
mikejacob's user avatar
  • 111
0 votes
1 answer
46 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 $...
KeynesCoeFen's user avatar
5 votes
1 answer
210 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 ...
Zuba Tupaki's user avatar
0 votes
0 answers
58 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 ...
computational_scientist's user avatar
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)\...
blockchain187's user avatar
3 votes
0 answers
50 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 ...
Stef1611's user avatar
  • 131
1 vote
1 answer
137 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, \...
David Leonardo Ramos's user avatar
5 votes
0 answers
92 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 ...
Peter Sanctus's user avatar
1 vote
3 answers
599 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 ...
user avatar
2 votes
1 answer
100 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 ...
Karim Chahine's user avatar
0 votes
0 answers
133 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 ...
Dmitry Kabanov's user avatar
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 ...
user avatar
1 vote
0 answers
33 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 ...
Craig Gidney's user avatar
2 votes
3 answers
1k 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 ...
Mateus de Oliveira's user avatar
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 ...
Teo Protoulis's user avatar
0 votes
1 answer
140 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. <...
ThermoRestart's user avatar
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 ...
user30385's user avatar
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 ...
Abaris's user avatar
  • 21
1 vote
2 answers
4k 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 ...
אבנר יעקב's user avatar
0 votes
1 answer
117 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 ...
user929304's user avatar
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. ...
fjarri's user avatar
  • 133
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$...
Airidas Korolkovas's user avatar
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 ...
Charles Wells's user avatar
3 votes
1 answer
166 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 ...
ugabooga's user avatar
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 ...
Libor's user avatar
  • 393
0 votes
2 answers
59 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 ...
theideasmith's user avatar
2 votes
1 answer
802 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 ...
computer-whisperer's user avatar
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 ...
Uri Cohen's user avatar
  • 177
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 ...
doetoe's user avatar
  • 593
1 vote
0 answers
101 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 ...
doetoe's user avatar
  • 593
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 ...
N. Virgo's user avatar
  • 1,223
2 votes
1 answer
162 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. ...
biz14's user avatar
  • 133
3 votes
1 answer
303 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 ...
Paul's user avatar
  • 12k
4 votes
1 answer
965 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 ...
Faheem Mitha's user avatar