Code Snippet: Mean, Variance, and Standard Deviation Methods
The methods to calculate mean, variance, and standard deviation of a vector of values. These are put here for easy reference, so that I do not need to rewrite them again.
A Helper Method for Performing K-Fold Cross Validation
The following method is a utility method for creating the K divisions upon which one is going to perform the K-fold cross validation operation. The input of the method is the length of the training data, and the number K. The output says which indices of the training-data is to be put in each division.
Code Snippet: Trimming Strings of White-space and control characters
The following method trims the given string of both white-space characters and control characters, and its rather fast!
Code Snippet: Determining how two intervals overlap
The following pieces of code help you figure out how two intervals overlap, and provides tools to represent them in a way that is useful for debugging purposes. This job is quite easy to accomplish, but since it is written too frequently each time from scratch, I have put them in this gist.
The IntervalOverlapKinds.cs file defines the IntervalOverlapKinds enumeration. The interval detection is carried out in the static methods of the IntervalOverlap class.
Code Snippet: Representing strings with all their characters visible
This piece of code is useful if you intend to work on a string processing algorithm. There are times, that you need to see the real content of a string while showing them in a windows form, console, and so on. This little method may help:
Code Snippet: Searching and Highlighting a token or string in a RichTextBox
Suppose that you intend to find a string or a token (i.e., whole word, instead of a substring) and change their color in some RichTextBox. The following code snippets will help. The FindStringAndSetColor method looks for instances of an arbitrary string in the contents of the RichTextBox, while the FindTokenAndSetColor method looks for whole words (tokens).
2 comments