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.

This tag should be used for questions related to programming solutions related to sampling.

Sampling can be done for functions varying in space, time, or any other dimension, and similar results are obtained in two or more dimensions. More information in Wikipedia - sampling (signal processing).

For statistical sampling, see Wikipedia - sampling (statistics) for more.

1593 questions
6
votes
5 answers

Pulling random files out of a folder for sampling

I needed a way to pull 10% of the files in a folder, at random, for sampling after every "run." Luckily, my current files are numbered numerically, and sequentially. So my current method is to list file names, parse the numerical portion, pull max…
physlexic
  • 826
  • 2
  • 9
  • 21
6
votes
3 answers

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 want to sample the dataframe with weight of…
Xin Chang
  • 87
  • 1
  • 5
6
votes
3 answers

Gaussian Process Posterior (Python)

I have created and sampled a jointly Gaussian prior with mean=0 using the code below: import numpy as np import matplotlib.pyplot as plt from math import pi from scipy.spatial.distance import cdist import scipy.stats as sts x_prior =…
user8188120
  • 883
  • 1
  • 15
  • 30
6
votes
7 answers

Resampling a sound sample, what filter do I use?

I am trying to resample a signal (sound sample) from one sampling rate, to a higher sampling rate. Unfortunately it needs some kind of filter, as some 'aliasing' appears to occur, and I'm not familiar with filters. Here is what I came up with: int…
Ledio Berdellima
  • 393
  • 1
  • 5
  • 10
6
votes
1 answer

low pass FIR filter - with no latency

I'm using a FIR filter to oversample audio. It's a simple typical windowed sinc, i.e. a sinc function truncated and windowed. As usual it requires past and 'future' samples to work. in practical terms this means the audio output is delayed. The…
Jeff
  • 402
  • 1
  • 6
  • 14
6
votes
4 answers

Lazily sample random results in python

Python question. I'm generating a large array of objects, which I only need to make a small random sample. Actually generating the objects in question takes a while, so I wonder if it would be possible to somehow skip over those objects that don't…
Verhoevenv
  • 147
  • 1
  • 4
6
votes
1 answer

"incorrect number of probabilities" error using sample()

I was trying sample(), however whenever I used custom probability in it ,it constantly displays "incorrect number of probabilities" I've tried pretty much everything but still stuck. Kindly guide me as to what I am doing…
blackhawk
  • 69
  • 1
  • 1
  • 5
6
votes
2 answers

R: Stratified random sample proportion of unique ID's by grouping variable

With the following sample dataframe I would like to draw a stratified random sample (e.g., 40%) of the ID's "ID" from each level of the factor "Cohort": data<-structure(list(Cohort = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,…
user3594490
  • 1,949
  • 2
  • 20
  • 26
6
votes
2 answers

Sampling from a bounded domain zipf distribution

I'd like to sample from "zipf" distribution from a bounded domain. That is, assume that the domain is {1,...,N}, I'd like each element in the domain, i, to be chosen with probability proportional to i ** -a, where a is a parameter of the…
R B
  • 543
  • 9
  • 25
6
votes
2 answers

AudioRecord object not initializing in a project

When I am trying to record an audio through my Nexus 5 using following code record = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_8BIT, BYTE_OF_SAMPLE *…
Kabir
  • 1,419
  • 17
  • 33
6
votes
1 answer

Is it possible to sample from a conditional density in R given some conditional data?

In R, using the np package, I have created the bandwidths for a conditional density. What I would like to do is, given some new conditional vector, sample from the resulting distribution. Current code: library('np') # Generate some test…
gdoug
  • 715
  • 1
  • 5
  • 16
6
votes
2 answers

Random sampling from a dataset, while preserving original probability distribution

I have a set of >2000 numbers, gathered from measurement. I want to sample from this data set, ~10 times in each test, while preserving probability distribution overall, and in each test (to extent approximately possible). For example, in each test,…
Ho1
  • 1,239
  • 1
  • 11
  • 29
6
votes
6 answers

How do I call CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer?

I'm trying to figure out how to call this AVFoundation function in Swift. I've spent a ton of time fiddling with declarations and syntax, and got this far. The compiler is mostly happy, but I'm left with one last quandary. public func…
nhgrif
  • 61,578
  • 25
  • 134
  • 173
6
votes
3 answers

Resampling from subject id's in R

Assume we have the following data set.seed(123) dat <- data.frame(var1=c(10,35,13,19,15,20,19), id=c(1,1,2,2,2,3,4)) (sampledIDs <- sample(min(dat$id):max(dat$id), size=3, replace=TRUE)) > [1] 2 4 2 The sampledIDs is a vector of id's that is…
Giuseppe
  • 786
  • 1
  • 7
  • 18
6
votes
1 answer

Visual Studio Profiler shows DLL name instead of Function name

I'm following the Profiling Tutorial here: http://msdn.microsoft.com/en-us/magazine/cc337887.aspx I've tried to profile the project by using CPU sampling. MSDN Results: My Results: I'm expecting to see System.Drawing.Bitmap.SetPixel instead of the…
David
  • 15,652
  • 26
  • 115
  • 156