function,machine-learning,statistics,sampling

B is better when the function does not have equal variance over all the inputs, which it probably does not. In the extreme case, imagine you have 1000 samples, 3 inputs, but only one of them actually affects the function. If you sample over a 10x10x10 regular grid, as in...

Just add the probabilities into sample using prob sample(c("sp.1", "sp.2", "sp.3"), 2, prob=c(1,2,3)) to repeat, you could wrap in replicate, e.g. 100 times: replicate(100, sample(c("sp.1", "sp.2", "sp.3"), 2, prob=c(1,2,3))) ...

debugging,warnings,verilog,sampling

(1) The trimmed FF/Latch warning is not due to non-blocking assignments. It is from 24 bits of the temp_buff register always being assigned to zeros. The RHS is 16bits; i_msb (4 bits), q_msb (4 bits), and temp_buff[31:24] (8 bits). And you are assigning it to a 32bit value. The assignment:...

From the docs on audioread, the output y is: Audio data in the file, returned as an m-by-n matrix, where m is the number of audio samples read and n is the number of audio channels in the file. Therefore it looks like your file has 2 audio channels. As...

This is because you are not properly indexing into your time series array to store the data. What you are doing is that you are only saving the last randomly chosen slice in your time series array. If you look at your loop closely, you are simply overwriting the output...

arrays,perl,random,sampling,resampling

This problem can be reframed into pulling 10,000 random numbers between 0 and 1 billion, where no number is within 100 of another. Brute Force - 5 secs Because you're only pulling 10,000 numbers, and probably don't need to do it very often, I suggest approaching this type of problem...

I'm not sure how the three fields fit into your question, but the power.prop.test() function does power calculations for differences in proportions. It looks like you would need about 600 samples per group to tell the difference between a 1% and a 4% incidence with 90% power ... power.prop.test(p1=0.01,p2=0.04,power=0.9,sig.level=0.05) ##...

I do not understand clearly the question, but regarding the error message: you are trying to sum a 295x295 matrix with a 1x295 vector, which fails: You probably mean: x=rand([1,length(t)]); instead of x=rand(length(t)); ...

In JPEG the different components are typically sampled differently. This is because the human eye is more perceptive to variations in luminance than color (chromacity). In your example, the luminance is sampled in full frequency (as always for JPEG), while both chromaicity components are subsampled 2x2 (or subsampled both horizontally...

android,accelerometer,frequency,smartphone,sampling

A small googling found Cochibos work on the subject. It takes the data gathered with the Accelerometer Frequency app and reports it to the web page. Looking for were the actual sample rate is defined it seems to be intrinsically connected with the device driver. I.e. the device driver sets...

First, you should reinstall the package BalancedSampling to make sure that you have the latest version 1.4. For me, it seems to work fine for N = 10 000 000 (takes about 30s to select a sample) library(BalancedSampling) N = 10000000; # population size n = 100; # sample size...

This doesn't answer your question about how to do this with the "sampling" package, but I've written a function called stratified that will do this for you. If you have "devtools" installed, you can load it like this: library(devtools) source_gist(6424112) Otherwise, just copy the code of the function from the...

signal.argrelmin is a thin wrapper around signal.argrelextrema with comparator=np.less. np.less(a, b) returns the truth value of a < b element-wise. Notice that np.less requires a to be strictly less than b for it to be True. Your data has the same minimum value at a lot of neighboring locations. At...

Base R solution: do.call(rbind, lapply(split(df,df$type1),function(i) i[sample(1:nrow(i),size = 10,replace=TRUE),])) EDIT: Other solutions suggested by @BrodieG with(DF, DF[unlist(lapply(split(seq(type), type), sample, 10, TRUE)), ]) with(DF, DF[c(sapply(split(seq(type), type), sample, 10, TRUE)), ]) ...

signal-processing,matlab,sampling

This will give you concentration values at the time points you wanted. You will have to put this inside the output_function_constrainedK2 function so that you can access the variables t and c_t. T=[0 0.25 0.50 1 1.5 2 3 4 9 14 19 24 29 34 39 44 49]; concentration=interp1(t,c_t,T)...

data frame with sample probabilities # in your case the rows are 1000 and the columns 4, # but it is just to show the procedure samp_prob <- data.frame(A = rep(.25, 4), B = c(.5, .1, .2, .2), C = c(.3, .6, .05, .05)) data frame of values to sample...

algorithm,social-networking,graph-algorithm,sampling,directed-graph

You can treat the undirected graph like a directed graph for the purposes of sampling. Any sampling strategy for a directed graph should work assuming it allows cycles. You simply want to sample the nodes and edges, so any edges that become part of the sample just accept the edge...

You might want to consider this as a possibility > set.seed(5) > examplecounts <- table(sample(c(1.2, 1.3, 1.4, 1.5), 50, replace=TRUE)) > examplecounts 1.2 1.3 1.4 1.5 13 13 11 13 > names(examplecounts)[which(examplecounts == max(examplecounts))] [1] "1.2" "1.3" "1.5" > as.numeric(names(examplecounts)[min(which(examplecounts==max(examplecounts)))]) [1] 1.2 Usually you will get a single value: try...

You can try n <- 2 df[with(df, transactionID %in% sample(unique(transactionID),n, replace=FALSE)),] # transactionID desc #1 1 a #2 1 d #3 1 a #17 8 f #18 8 d data df <- structure(list(transactionID = c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 5L, 5L, 5L, 5L, 6L, 7L, 7L, 7L,...

raspberry-pi,sampling,i2c,gpio,inertial-navigation

Solved it by using SPI instead of I2C. Now I can get data at stable 2000HZ sampling rate.

A simple way would be to shuffle your population so the initial ordering is random (if it's not already random). Then take elements from the end and remove them. You can get the elements by slicing population[-sample_size:] and remove them using population[-sample_size:] = []. import random population = list(range(100)) #...

java,hadoop,mapreduce,sampling

I would definitely go with your first option. I'm not sure why you need a reducer though. Just filter out 20% in the map phase and call it a day.

matlab,distribution,sampling,random-sample

So, you can use this, for example: y = 0.8 + rand*0.4; this will generate random number between 0.8 and 1.2. because rand creates uniform distribution I believe that rand*0.4 creates the same ;) ...

audio,swift,initialization,avfoundation,sampling

Disclaimer: I have just tried to translate the code from Reading audio samples via AVAssetReader to Swift, and verified that it compiles. I have not tested if it really works. // Needs to be initialized somehow, even if we take only the address var audioBufferList = AudioBufferList(mNumberBuffers: 1, mBuffers: AudioBuffer(mNumberChannels:...

I have found the workaround. Firstly i Split the dataset into folds and saved them as train/test arff. Then i performed the remove filter on the dataset which results in a stratified sample as above

android,accelerometer,sampling

If you want to match the hardware-provided time (event.timestamp) and the System time you can do this by adjusting the times. Usually the times are not the same, but they just differ by a constant amount of milliseconds. I suggest you to print out both times and compare them. You...

Some approximation to the graph (1) is: curve(dnorm(x,5 ,sqrt(1/9)), xlim=c(0, 14), ylab='', lwd=2, col='blue') curve(dnorm(x,4.2,sqrt(1/9)), add=T, lwd=2) curve(dnorm(x,5,1), add=T, col='blue') curve(dnorm(x,4.2,1), add=T) legend('topright', c('Samp. dist. for mu=5','Samp. dist. for mu=4.2', 'N(5,1)','N(4.2,1)'), bty='n', lwd=c(2,2,1,1), col=c(4,1,4,1)) ...

The reason seems to be the introduction of thinning into your Gibbs sampling. Thinning is used to reduce the effect of correlation between consecutive samples. Gibbs sampling generates a Markov Chain of samples and the nearby samples are correlated, while typically the intention is to draw samples that are independent....

Firstly you should look into the SIR (Sequential Importance Sampling Re-sampling) Particle Filter [PF] (Or Sequential Monte-Carlo Methods is the other name it is known by). I recommend the book called by Arnaud Doucet & Neil Gordon called "Sequential Monte Carlo Methods in Practice". It contains practically the state of...

adobe,sampling,adobe-analytics

Adobe Analytics does not have any built-in method for sampling data, neither on their end nor in the js code. DTM doesn't offer anything like this either. It doesn't have any (exposed) mechanisms in place to evaluate all requests made to a given property (container); any rules that extend state...

matlab,random,distribution,gaussian,sampling

Might use Irwin-Hall from https://en.wikipedia.org/wiki/Irwin%E2%80%93Hall_distribution Basically, min(IH(n)) = 0 max(IH(n)) = n peak(IH(n)) = n/2 Scaling to your [1.9...2.1] range v = 1.9 + ((2.1-1.9)/n) * IH(n) It is bounded, very easy to sample, and at large n it is pretty much gaussian. You could vary n to get narrow...

time-series,sampling,measurement,probability-theory

I'm going to approach this problem as if it were on a test. First, let's name the variables. Bx is value of the boolean variable after x opportunities to flip (and B0 is the initial state). P is the chance of changing to a different value every opportunity. Given that...

java,android,sampling,audiorecord

You could check if 44100 is supported by your device. Android does not provide an explicit method to check it but there is a work-around with AudioRecord class' getMinBufferSize function. public void getValidSampleRates() { for (int rate : new int[] {8000, 11025, 16000, 22050, 44100}) { // add the rates...

You could try data.table library(data.table) setDT(df)[freq %in% r,sample(id,1L) , freq] Or using base R aggregate(id~freq, df, subset=freq %in% r, FUN= sample, 1L) Update If you have a vector "r" with duplicate values and want to sample the data set ('df') based on the length of unique elements in 'r' r...

I was thinking of equal spacing (around 91 days between appointments) in a year starting at the first appointment... Essentially one appointment per quarter of the year. # Find how many days in a quarter of the year quarter = floor(365/4) first = sample(days, 1) all = c(first, first +...

matlab,audio,frequency,sampling

You should just use the variable y and reshape it to form your split audio. For example, chunk_size = fs*0.03; y_chunks = reshape(y, chunk_size, 6000); That will give you a matrix with each column a 30 ms chunk. This code will also be faster than reading small segments from file...

python,numpy,statistics,scipy,sampling

faster than the other's as far as i can see. But probably uses more memory. import random from collections import Counter def sample2(A,N): distribution = [i for i, j in enumerate(A) for _ in xrange(j)] sample = Counter(random.sample(distribution, N)) return [sample[i] for i in xrange(len(A))] In [52]: A = np.random.randint(0,...