sampling
What are chunks, samples and frames when using pyaudio
“RATE” is the “sampling rate”, i.e. the number of frames per second “CHUNK” is the (arbitrarily chosen) number of frames the (potentially very long) signals are split into in this example Yes, each frame will have 2 samples as “CHANNELS=2”, but the term “samples” is seldom used in this context (because it is confusing) Yes, … Read more
How to generate a random 4 digit number not starting with 0 and having unique digits?
We generate the first digit in the 1 – 9 range, then take the next 3 from the remaining digits: import random # We create a set of digits: {0, 1, …. 9} digits = set(range(10)) # We generate a random integer, 1 <= first <= 9 first = random.randint(1, 9) # We remove it … Read more
Random Sample of a subset of a dataframe in Pandas
You can use the sample method*: In [11]: df = pd.DataFrame([[1, 2], [3, 4], [5, 6], [7, 8]], columns=[“A”, “B”]) In [12]: df.sample(2) Out[12]: A B 0 1 2 2 5 6 In [13]: df.sample(2) Out[13]: A B 3 7 8 0 1 2 *On one of the section DataFrames. Note: If you have a … Read more
Abysmal OpenCL ImageSampling performance vs OpenGL TextureSampling
I suspect there is some issue with OpenCL in latest NVidia drivers on some video cards. Here and here are some reports about those. Try to repeat test on GPU from another family.
Algorithms for determining the key of an audio sample
It’s worth being aware that this is a very tricky problem and if you don’t have a background in signal processing (or an interest in learning about it) then you have a very frustrating time ahead of you. If you’re expecting to throw a couple of FFTs at the problem then you won’t get very … Read more
What does replacement mean in numpy.random.choice?
It controls whether the sample is returned to the sample pool. If you want only unique samples then this should be false.
Take n random elements from a List?
Two main ways. Use Random#nextInt(int): List<Foo> list = createItSomehow(); Random random = new Random(); Foo foo = list.get(random.nextInt(list.size())); It’s however not guaranteed that successive n calls returns unique elements. Use Collections#shuffle(): List<Foo> list = createItSomehow(); Collections.shuffle(list); Foo foo = list.get(0); It enables you to get n unique elements by an incremented index (assuming that the … Read more