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
9
votes
3 answers

what is the difference between sampled_softmax_loss and nce_loss in tensorflow?

i notice there are two functions about negative Sampling in tensorflow to compute the loss (sampled_softmax_loss and nce_loss). the paramaters of these two function are similar, but i really want to know what is the difference between the two?
王乐义
  • 91
  • 1
  • 3
9
votes
2 answers

How to equidistant resample a line (or curve)?

I have a line l_1 given with a point series p_1,...,p_n. I now want a new line l_2 having k points: q_1,...,q_k. But for all i \in {1,...,k-1}: abs( q_i - q_i+1 ) = const, meaning the segments of l_2 are equidistant or uniform. k >= 2 and p_1 and…
math
  • 8,514
  • 10
  • 53
  • 61
9
votes
3 answers

Sampling from MultiIndex DataFrame

I'm working with the following panel data in a MultiIndex pandas DataFrame called df_data: y x n time 0 0 0.423607 -0.307983 1 0.565563 -0.333430 2 0.735979 -0.453137 3 …
J Jung
  • 93
  • 1
  • 6
9
votes
1 answer

How to sample on condition with pandas?

I hava a dataframe df like the following: Col1 Col2 0 1 T 1 1 B 2 3 S 3 2 A 4 1 C 5 2 A etc... I would like to create two dataframes: df1 is a random sample of 10 rows such that…
Bob
  • 10,741
  • 27
  • 89
  • 143
9
votes
2 answers

Android MediaRecorder Sampling Rate and Noise

I have an issue using Android's MediaRecorder to record sound from microphone to .m4a files (AAC-LC, MPEG-4 container). Starting from API level 18, the default sampling rate drops from 44.1 or 48 kHz (depending on device) to only 8 Hz. If I…
user4672580
9
votes
2 answers

Audio sample frequency rely on channels?

If you have audio encoded at 44100Hz that means you have 44100 samples per second. Does this mean 44100 samples/sec for a channel, or for all channels? For example if a song is stereo and encoded at 44100Hz, are there 44100 sample/sec for both…
goocreations
  • 2,938
  • 8
  • 37
  • 59
9
votes
4 answers

How to select points at a regular density

how do I select a subset of points at a regular density? More formally, Given a set A of irregularly spaced points, a metric of distance dist (e.g., Euclidean distance), and a target density d, how can I select a smallest subset B that satisfies…
h2kyeong
  • 447
  • 3
  • 13
8
votes
2 answers

How do I Sample each group from a pandas data frame at different rates

I have a data frame containing information about a population that i wish to generate a sample from. I also have a dataframe sample_info that details how many units of each group in the population dataframe I need in my sample. I have developed some…
Ryan
  • 142
  • 6
8
votes
2 answers

Why does random sampling scale with the dataset not the sample size? (pandas .sample() example)

When sampling randomly from distributions of varying sizes I was surprised to observe that execution time seems to scale mostly with the size of the dataset being sampled from, not the number of values being sampled. Example: import pandas as…
c_layton
  • 83
  • 6
8
votes
2 answers

How to sample/partition panel data by individuals( preferably with caret library)?

I would like to partition panel data and preserve the panel nature of the data: library(caret) library(mlbench) #example panel data where id is the persons identifier over years data <-…
Googme
  • 914
  • 7
  • 27
7
votes
5 answers

Randomly sampling unique subsets of an array

If I have an array: a = [1,2,3] How do I randomly select subsets of the array, such that the elements of each subset are unique? That is, for a the possible subsets would be: [] [1] [2] [3] [1,2] [2,3] [1,2,3] I can't generate all of the possible…
meagerf
  • 71
  • 1
  • 2
7
votes
7 answers

name of algorithm related to load balancing / re-distribution

Given an array [x1, x2, x3, ..., xk ] where xi is the number of items in box i, how can I redistribute the items so that no box contains more than N items. N is close to sum(xi)/k -- That is, N is close to every box having the same number of items.…
Gus
  • 4,375
  • 5
  • 31
  • 50
7
votes
0 answers

Sampling from a joint distribution in Pyro

I understand how to sample from multidimensional categorical, or multivariate normal (with dependence within each column). For example, for a multivariate categorical, this can be done as below: import pyro as p import pyro.distributions as d import…
alpaca
  • 1,211
  • 13
  • 23
7
votes
3 answers

Resampling of two data sets of different length in MATLAB

I have two vectors: sensorA of length 927 and sensorB of length 1250. I would like to make them of the same length. The resample() function in MATLAB is very noisy at the edges and I need atleast reasonably good accuracy throughout. I understand…
Imelza
  • 301
  • 1
  • 7
  • 19
7
votes
2 answers

Sampling from a given probability distribution using R

Given the probability distribution as follows: x-coordinate represents hours, y-coordinate means the probability for each hour. The problem is how to generate a set of 1000 random data that follows the probability distribution?
Gamp
  • 309
  • 1
  • 5
  • 15