sampling

PHP randomly select from a list

こ雲淡風輕ζ 提交于 2019-12-23 20:13:03
问题 I am currently working with PHP code that random selects colors: <div onclick="location.href='<?php the_permalink() ?>';" style="cursor:pointer;background:#<?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?><?php echo rand(0, 9); ?>;" class="post bg thickbox" id="thickbox post-<?php the_ID(); ?>"> What I would prefer to do is define a list of preferred colors in one PHP file, and then randomly sample an element from

Memory sampling with jvisualvm

一笑奈何 提交于 2019-12-22 11:24:01
问题 I am using memory sampling feature of Java Visual VM and I can't answer the questions: Why are there so many instances created? Why does these numbers of instances and bytes keep increasing? For instance, I created a very simple Java program as follow: public class TestMemory{ public static void main(String[] args) throws InterruptedException { System.out.println("Hello"); Thread.sleep(60 * 60 * 1000); } } And I can see in Java Visual VM that there are 611 classes. The number of instances

FFmpeg and types of samples

别等时光非礼了梦想. 提交于 2019-12-21 21:25:04
问题 Decoded audio using FFmpeg (function avcodec_decode_audio3) and try to reproduce it through Audiotrack in Android. When playing I hear some growling. No music. On the forums advised that the problem with the samples. Question: how to solve this problem, if it is associated with a mismatch of types of samples? Code decoding: while (av_read_frame(pFormatCtx, &packet)>= 0) { if (aCodecCtx->codec_type == AVMEDIA_TYPE_AUDIO) { int data_size = AVCODEC_MAX_AUDIO_FRAME_SIZE * 2; int size=packet.size;

Select cells randomly from NumPy array - without replacement

。_饼干妹妹 提交于 2019-12-21 07:23:11
问题 I'm writing some modelling routines in NumPy that need to select cells randomly from a NumPy array and do some processing on them. All cells must be selected without replacement (as in, once a cell has been selected it can't be selected again, but all cells must be selected by the end). I'm transitioning from IDL where I can find a nice way to do this, but I assume that NumPy has a nice way to do this too. What would you suggest? Update: I should have stated that I'm trying to do this on 2D

Profiling a (possibly I/O-bound) process to reduce latency

这一生的挚爱 提交于 2019-12-20 12:33:03
问题 I want to improve the performance of a specific method inside a larger application. The goal is improving latency (wall-clock time spent in a specific function), not (neccessarily) system load. Requirements: As I expect a lot of the latency to be due to I/O, take into account time spent waiting/blocked (in other words: look at wall clock time instead of CPU time) As the program does much more than the fragment i'm trying to optimize. There needs to be a way to either start/stop profiling

Sampling small data frame from a big dataframe

和自甴很熟 提交于 2019-12-20 02:08:50
问题 I am trying to sample a data frame from a given data frame such that there are enough samples from each of the levels of a variable. This can be achieved by separating the data frame by the levels and sample from each of those . I thought ddply (data-frame to data-frame) would do it for me. Taking a minimal example: set.seed(1) data1 <-data.frame(a=sample(c('B0','B1','B2'),100,replace=TRUE),b=rnorm(100),c=runif(100)) > summary(data1$a) B0 B1 B2 30 32 38 The following commands perform the

How do I call CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer?

只愿长相守 提交于 2019-12-19 07:49:14
问题 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 captureOutput( captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection! ) { let samplesInBuffer = CMSampleBufferGetNumSamples(sampleBuffer) var audioBufferList: AudioBufferList var

accurate sampling in c++

早过忘川 提交于 2019-12-19 04:13:24
问题 I want to sample values I get from a gpio 4000 times per second, currently I do something like that: std::vector<int> sample_a_chunk(unsigned int rate, unsigned int block_size_in_seconds) { std::vector<std::int> data; constexpr unsigned int times = rate * block_size_in_seconds; constexpr unsigned int delay = 1000000 / rate; // microseconds for (int j=0; j<times; j++) { data.emplace_back(/* read the value from the gpio */); std::this_thread::sleep_for(std::chrono::microseconds(delay)); }

Change the playback rate of a track in real time on Android

我的梦境 提交于 2019-12-19 04:11:57
问题 I would like to know if somebody knows a library to changing the playback rate of a track in real time. My idea is to load a track and change its playback rate to half or double. Firstly, I tried with MusicPlayer but is was not possible at all and then I tried with SoundPool. The problem is that with SoundPool I can´t change the rate once the track is loaded. Here is the code I am using (proof of concept): float j = 1; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

OpenCV, how to use arrays of points for smoothing and sampling contours?

﹥>﹥吖頭↗ 提交于 2019-12-18 11:27:42
问题 I have a problem to get my head around smoothing and sampling contours in OpenCV (C++ API). Lets say I have got sequence of points retrieved from cv::findContours (for instance applied on this this image: Ultimately, I want To smooth a sequence of points using different kernels. To resize the sequence using different types of interpolations. After smoothing, I hope to have a result like : I also considered drawing my contour in a cv::Mat , filtering the Mat (using blur or morphological