Questions tagged [sampling]
In signal processing, sampling is the reduction of a continuous signal to a discrete signal. In statistics, sampling is the selection of a subset of individuals from within a statistical population to estimate characteristics of the whole population.
sampling
1,610
questions
0
votes
0
answers
4
views
Changing pick chance of multiple elements in weighted set
I have a weighted set implementation that works off a map in the data structure:
class WeightedSet<T> {
Map<T, Double> weights = new HashMap<>();
double sum;
}
This ...
8
votes
1
answer
3k
views
Pandas: Sampling from a DataFrame according to a target distribution
I have a Pandas DataFrame containing a dataset D of instances drawn from a distribution x. x may be a uniform for example.
Now, I want to draw n samples from D, sampled according to some new ...
0
votes
0
answers
29
views
create random sample conditionally using a file
I am trying to assign reviewers to projects with the condition that the author of the project cannot be assigned as a reviewer to a project in their own portfolio.
I created a dataset with variables ...
0
votes
0
answers
22
views
using mstage() in R to draw stratified samples
I trying to use the mstage() function in R to draw a multi-stage stratified sample and don't know how to. I wonder if anyone can help?
The data is in the end.
What I want to achieve is:
At the first ...
0
votes
0
answers
20
views
Monte Carlo Example using Accept Reject Method
I implemented a Pi estimation program in C, that is I generate a pair of PRNs using LCG algorithm, and then I compute their coordinates to see if they fall within a unit disk, as referenced here https:...
0
votes
1
answer
28
views
How to weight samples with sklearns's cross_validate for scoring only?
I am running a regression task on a dataset which is composed of both authentic and augmented samples. The augmented samples are generated by jittering the authentic ones. I would like to select the ...
2
votes
1
answer
2k
views
Integration of always positive input is negative in Simulink
In MATLAB/Simulink I have calculated integration of a signal which is always positive:
However, the integration result of this signal is negative!!!
How is it possible?
-1
votes
1
answer
46
views
Is it efficient to pass model into a custom dataset to run model inference during training for sampling strategy? [closed]
I'm trying to design a training flow for sampling samples during training.
My data look like this:
defaultdict(list,
{'C1629836-28004480': [0, 5, 6, 12, 17, 19, 28],
'C0021846-...
0
votes
0
answers
16
views
Get specific number of samples from audio
I have an audio file and corresponding video (which were recorded synchronously) and I'd like to match up every frame of the video to a corresponding pitch using the praat-parselmouth package.
First, ...
0
votes
1
answer
31
views
tms-NET sampling in Python
I have been trying find some pre-implementation of tms-NET sampling in python (as I couldn't implement by myself) for my projects wherein I want to perform sampling on numpy array of shape (...
0
votes
1
answer
41
views
How to use balanced sampler for torch Dataset/Dataloader
My simplified Dataset looks like:
class MyDataset(Dataset):
def __init__(self) -> None:
super().__init__()
self.images: torch.Tensor[n, w, h, c] # n images in memmory - ...
4
votes
5
answers
8k
views
drawing a stratified sample in R
Designing my stratified sample
library(survey)
design <- svydesign(id=~1,strata=~Category, data=billa, fpc=~fpc)
So far so good, but how can I draw now a sample in the same way I was able for ...
0
votes
1
answer
128
views
Efficient Equidistant Point Sampling on Closed Contours in OpenCV
For a project, I extracted closed contours from silhouette images (MPEG-7 Core Experiment CE-Shape-1 Test Set) using OpenCV’s findContours with RETR_EXTERNAL and CHAIN_APPROX_NONE. I need an efficient ...
0
votes
0
answers
39
views
In statistical modeling: sampling with replacement or without replacement?
I want to sample a population with systematic and cluster sampling methods and use these samples in linear regression modeling. For this, should I do sampling with replacement or without replacement?
...
1
vote
1
answer
27
views
Sampling with Replacement/Bootstrap in Oracle SQL
This is my first question to the stack overflow.
We are doing statistics for simulation data and I wanted to implement the bootstrap in Oracle-SQL (sampling data with replacement). My approach is as ...
6
votes
3
answers
6k
views
sampling with weight using pyspark
I have an unbalanced dataframe on spark using PySpark.
I want to resample it to make it balanced.
I only find the sample function in PySpark
sample(withReplacement, fraction, seed=None)
but I ...
0
votes
0
answers
61
views
Latin Hypercube sampling with constraints
I want to generate say about 500 samples of 36 variables using Latin Hypercube sampling to ensure good coverage of the parameter spaces.
I also want to ensure each sample meets some constraint.
from ...
1
vote
1
answer
52
views
Sampling transformation - rexp vs rweibull
I am working with different sampling functions, and I am wondering why these two formulations do not give the same result
n=2
set.seed(1)
rweibull(n,shape = 1,scale = 1)
# [1] 1.3261078 0.9885284
set....
0
votes
0
answers
26
views
Implementing Latin Hypercube sampling from skewed distributions in Java
I have 5 parameters represented by skewed discrete distributions. I want to do Latin Hypercube sampling from these distributions. Most of the examples I could find on the internet use LHS from normal ...
-1
votes
1
answer
28
views
Plot of the two dataset having different sampling rate with proper alignment
I have two dataset are the sensor values recorded with different equipment with different sampling rate. I want to plot both in same graph and it's peak should be aligned so that we can compare it ...
0
votes
0
answers
26
views
Ploting of the two dataset having different sampling rate
number of peaks I am getting is equal with dataset1 and dataset2 but since sampling rates are different for both data set .I am unable to plot such that its peak look aligned.
I want to optimise the ...
1
vote
0
answers
74
views
How do I simulate Bayes theorem in R to get a sense of uncertainty?
Okay, so Bayes theorem is p(A|B) = p(A) * P(B|A) * 1/p(B).
I want to simulate p(A|B) using all the uncertainty surrounding p(A), p(B|A) and p(B).
rbeta seems like a good choice.
data: imagine I just ...
0
votes
0
answers
68
views
Adafruit ESP32-C3 ADC sampling rate issue when sending real time sine wave
So we have this project which is about sending data using Adafruit QT Py ESP32-C3 Bluetooth module to another device and visualizing it, we are stuck at some point and we are facing a problem with the ...
0
votes
0
answers
25
views
Simulating Cox-PH data in Python
Suppose I want to sample from the cox-PH model. I have some covariates and my baseline hazard function is $2t$.
Is there are an easy method to do so?
0
votes
1
answer
29
views
How can I parameterize lags parameters for each independent variable in my model in PyMC (5.10.0)?
I am new to PyMC and I am using the 5.10.0 version. I am running a simple Media Mix Model and I need to parameterize the individual lags between the independent(media activity) and the dependent(sales ...
2
votes
1
answer
93
views
How can I fix the problem of a single PSU when use "samplics" in Python?
I am using the package "samplics" to work with a complex survey. At the beginin I use the follow sequence:
import numpy as np
import pandas as pd
import pyreadr
import samplics
from samplics....
1
vote
1
answer
55
views
What's an elegant way to avoid "hopping" quantization errors when graphing a divergent 2D function?
I have some Qt-based software that graphs an audio-transform function in 2D (with frequency-in-Hz as the X axis, and decibels-gain on the Y axis).
It does this by choosing a set of X positions to ...
0
votes
0
answers
23
views
How many partitions should be used for a latin hypercube sample, versus computational time
I'm running a sensitivity analysis on an epidemiological model and I have 14 parameters which are uncertain.
I'm using the maximinLHS command from the 'lhs' package in R (Version 2023.06.1+524), and ...
5
votes
5
answers
391
views
Improve the performance of recursive sampling function
As a follow-up to my previous question, I'm interested in improving the performance of the existing recursive sampling function.
By recursive sampling I mean randomly choosing up to n unique unexposed ...
0
votes
0
answers
14
views
Creating a tensor of samples from posterior predictive based on test data shaped differently than training data
How do I allow a pymc model to sample from a posterior predictive when a matrix of training data has shape (66289, 1024) and a matrix of test data has shape (2054937, 1024)? In other words, how do I ...
0
votes
0
answers
23
views
Domain error in arguments for iterated sampling from sequence of MM1 queue models
Here is my minimum working example:
import numpy as np
from scipy.special import iv
from scipy.stats import rv_discrete
class mm1_len(rv_discrete):
"Distribution of number of customers in a ...
0
votes
2
answers
235
views
Stratified sampling for semantic segmentation
I have a set of images and multi-label masks (an image usually has segments of more than one class) and I would like to split it into train and validation sets. The data is imbalanced, where two of ...
1
vote
1
answer
84
views
The difference between using fft2 in matlab for odd and even matrices
I want to perform Fourier transform on a two-dimensional center-symmetric disk in matlab. The specific code is as follows.
N = 20;
matrix = zeros(N, N);
diameter = 20;
radius = diameter / 2;
...
1
vote
3
answers
69
views
Quasi-random equal assortment
I am trying to write a script to allocate moderators/second markers to essays that have already been marked but I am struggling to get it right.
There are two main conditions I have:
As the markers ...
0
votes
1
answer
46
views
R: sample equal Ns, within groups
I have a data set, in which observations are divided into groups and subgroups, and into types.
Here's an example of such data:
data <- data.frame(group = sample(c(1:30), 10000, replace = ...
0
votes
0
answers
11
views
Independent sampling with at least two elements, without re-sampling
Suppose we have a sequence of numbers (WLOG, [n]) and we want to sample elements from it into a set $S$, where each element is sampled independently at random with
$p_i := Pr[i \in S] \in (0, 1), for ...
0
votes
0
answers
58
views
How to Sample from a DataFrame in Pandas to Match a Target Distribution with Specific Variables
I'm working with a large DataFrame in Pandas, containing about 800,000 observations. I need to create a sample from this DataFrame that approximates a target distribution. The sample size should be ...
2
votes
4
answers
4k
views
PyTorch: How to sample from a tensor where each value in the tensor has a different likelihood of being selected?
Given tensor
A = torch.tensor([0.0316, 0.2338, 0.2338, 0.2338, 0.0316, 0.0316, 0.0860, 0.0316, 0.0860]) containing probabilities which sum to 1 (I removed some decimals but it's safe to assume it'll ...
0
votes
0
answers
61
views
MaxMin diversity selection with RDKit
I cannot find a detailed exposition of the Leader algorithm used to perform MaxMin diversity picking. The documentation (https://www.rdkit.org/docs/source/rdkit.SimDivFilters.rdSimDivPickers.html) ...
2
votes
2
answers
60
views
Stratified sampling based on two population benchmark distributions
I am having trouble figuring out an existing way or writing new code to use stratified sampling from a dataset framework against two different population benchmark distributions. Since I am not 100% ...
93
votes
13
answers
75k
views
Take n random elements from a List<E>?
How can I take n random elements from an ArrayList<E>? Ideally, I'd like to be able to make successive calls to the take() method to get another x elements, without replacement.
2
votes
0
answers
22
views
Probability 0 in Importance Sampling
I have a general question about the methods that use importance sampling in RL. What happens when the probability of either one of the policies is 0?
7
votes
6
answers
8k
views
Convert SoundFont to .wav files for each note
Is there a simple way of converting a sound font file to .wav files (or any common music format, really), separate for each note?
So let's say I had a sound font a.sfz; I would like to get out of it ...
0
votes
1
answer
137
views
How to sample from a Burr-Type XII distribution in Python?
I'm need to sample from a Burr-Type XII distribution with zero mean and unit variance in Python. In scipye there is scipy.stats.burr12 which seems the right thing to use. However, it is not clear to ...
1
vote
3
answers
75
views
Select random rows until threshold value from other column is reached
I have an SF-object in R. It looks as follows:
Type Value Geometry
A 1 ()
A 3 ()
B 2 ()
A 1 ()
C 4 ()
In the geometry column, the ...
0
votes
0
answers
18
views
pymc3 sampling chain 0 failed
I am trying to extract parameters for a model y=theta[0]*x+theta[1]*x**2. However when I run pymc3.sample after a short time the code crashes with an error message chain 0 failed. Any ideas how to fix ...
4
votes
2
answers
953
views
Why does my train loss jump down when a new epoch starts?
When I train a neural network consisting of 2 convolutional and 2 fully connected layers on the MNIST handwritten digits task, I receive the following train loss curve:
The datasets contains 235 ...
2
votes
1
answer
55
views
sample a predefined number of observations per group
My data looks like this:
> data|>head(20)|>dput()
structure(list(id = c("42190204", "34390202", "34310104", "34310104",
"34310104", "...
0
votes
0
answers
20
views
T-distribution, to use or to not use
The question is asking to find if probability of having average low or low as 18?
I have mu = 20, n = 25, X bar = 18, and std dev = 2
Since I do not have variance, I assume I am supposed to use t-...
0
votes
0
answers
28
views
Applying tail sampling policy on two seprate collectors- Aggregating spans
I'm using 2 separate collectors to send traces from my frontend and backend apps. One collector is receiving traces on port 4318 from the frontend app and the other collector is receiving traces on ...