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
1 answer

Sampling using an id variable

I know how to do ordinary random sampling using R: mysample <- mydata[sample(1:nrow(mydata), 100),] However, I want to sample by id variables. Let me explain - my dataset looks like this: id var1 var2 ... 1 5.1 1.2 1 4.7 0.9 2 3.3 1.6 3 3.4 …
histelheim
  • 4,938
  • 6
  • 33
  • 63
6
votes
3 answers

Android accelerometer: Sampling Rate?

I want to [1] Increase Sampling Rate of my phone's accelerometer. (SENSOR_DELAY_FASTEST gives max. about 100Hz on Xperia/ 180Hz on Nexus4, I want delay to be about 1ms or less for my work. [2] If [1] not possible can i make Rate…
pxm
  • 1,611
  • 2
  • 18
  • 34
6
votes
2 answers

Efficient way to sample from different probability vectors

I'm looking for a more efficient way to sample from a list of integers 1:n, multiple times, where the probability vector (also length n) is different each time. For 20 trials with n = 10, I know one can do it like this: probs <- matrix(runif(200),…
lukeholman
  • 595
  • 6
  • 14
6
votes
2 answers

How can I sample from a complex or compound distribution in Haskell?

I'm trying to generate random masses for hypothetical planets in Haskell. I want to produce these masses by sampling a bi-modal distribution (ideally the superposition of two normal distributions: one corresponding to small planets and one…
6
votes
2 answers

Simulate samples from a joint cumulative distribution function?

I have a joint density function for two independent variables X and Y. And I now want to sample new x,y from this distribution. What I believe I have to do is to find the joint cumulative distribution and then somehow sample from it. I kinda know…
Groot
  • 13,943
  • 6
  • 61
  • 72
5
votes
4 answers

How to convert a .WAV audio data sample into an double type?

I'm working on an application that processes audio data. I'm using java (I've added MP3SPI, Jlayer, and Tritonus). I'm extracting the audio data from a .wav file to a byte array. The audio data samples I'm working with are 16 bits stereo.…
dedalo
  • 2,541
  • 12
  • 32
  • 34
5
votes
2 answers

What is the fastest way to sample slices of numpy arrays?

I have a 3D (time, X, Y) numpy array containing 6 hourly time series for a few years. (say 5). I would like to create a sampled time series containing 1 instance of each calendar day randomly taken from the available records (5 possibilities per…
Jahfet
  • 279
  • 4
  • 11
5
votes
3 answers

FFT - When to window?

I've seen the various FFT questions on here but I'm confused on part of the implementation. Instead of performing the FFT in real time, I want to do it offline. Lets say I have the raw data in float[] audio. The sampling rate is 44100 and so…
Skoder
  • 3,983
  • 11
  • 46
  • 73
5
votes
4 answers

Efficient random sampling from a huge list

I have a data file with a large number of values (53,000,000+) and I would like to pull out a random subset of n of these values (say, 2,000,000). I implemented a Perl script that pulls the list into memory, uses the Fisher-Yates method to shuffle…
Daniel Standage
  • 8,136
  • 19
  • 69
  • 116
5
votes
2 answers

What is the difference between Linear Quantization and Non-linear Quantization?

What is the difference between Linear Quantization and Non-linear Quantization ? I'm talking with regard to PCM samples. http://www.blurtit.com/q927781.html has an article about it but I'm looking for a more elaborate answer.
Namratha
  • 16,630
  • 27
  • 90
  • 125
5
votes
1 answer

sampling a multimensional posterior distribution using MCMC Metropolis-Hastings algo in R

I am quite new in sampling posterior distributions(so therefore Bayesian approach) using a MCMC technique based on Metropolis-Hastings algorithm. I am using the mcmc library in R for this. My distribution is multidimensionnal. In order to check if…
5
votes
2 answers

Controlling volume of a Clip when using Java Sound (javax,sound.sampled)

I'm using Java sound to play back a number of sound samples with the Clip.start() method. Given this, what is the best way to control the playback volume? In particular, I'm very keen that the solution will work reliably across platforms.
mikera
  • 105,238
  • 25
  • 256
  • 415
5
votes
3 answers

Matching vector values by records in a data frame in R

I have a vector of values r as follows: r<-c(1,3,4,6,7) and a data frame df with 20 records and two columns: id<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,1,4,15,16,17,18,19,20) freq<-c(1,3,2,4,5,6,6,7,8,3,3,1,6,9,9,1,1,4,3,7,7) …
AliCivil
  • 2,003
  • 6
  • 28
  • 43
5
votes
1 answer

Uneven number of samples between Accelerometer, Gyro and Magnetometer on Android

I am developing an Android app that records the inertial data on a smartphone to then further processes it. Different Android devices have different behaviors depending on the firmware interfacing the inertial sensors to Android and that's crystal…
eykiriku
  • 93
  • 1
  • 9
5
votes
2 answers

c++ discrete distribution sampling with frequently changing probabilities

Problem: I need to sample from a discrete distribution constructed of certain weights e.g. {w1,w2,w3,..}, and thus probability distribution {p1,p2,p3,...}, where pi=wi/(w1+w2+...). some of wi's change very frequently, but only a very low proportion…
therefore
  • 49
  • 5