For my current project, I’m doing some statistical analysis. Part of that requires finding the mean and standard deviation for my collection of samples.
Because of the data source, I need to use the formula for “Population Standard Deviation” which is a little different from the formula for “Standard Deviation.” The denominator is “n” instead of “n – 1”. The word from my client is that in sample sizes over 20 the difference between the two formulas is negligible. Since we are running tests in a 96 well microplates, my sample count could be very low. Especially when you factor in the multiple sample sources, calibration samples and quality control samples on each microplate.
Read more…
(Another snippet I originally posted to CodeKeep.)
I needed to create a RichTextBox with a title, menu path, and description. Here’s how I made customized the visuals to suit the project. Title is enlarged and made bold. Menu is reduced and made italics. The description is ‘standard.’
Code:
Read more…
(Another snippet I originally posted to CodeKeep.)
Code:
var myList = new List<string>() { "one", "two", "three" };
// print out the original list
foreach (string item in myList)
Console.WriteLine(item); // one two three
myList.Remove("two");
// print out the new list
foreach (string item in myList)
Console.WriteLine(item); // one three
Notes:
You cannot remove items from a list inside of a foreach. You can set items to null, but you cannot remove the items.
You have a list of “something” and you want to remove items from the list. I can think of a couple ways to do this.
Remove Items V1:
List myList = new List() { "one", "two", "three" };
// print out the original list
foreach (string item in myList)
Console.WriteLine(item); // one two three
myList.Remove("two");
// print out the new list
foreach (string item in myList)
Console.WriteLine(item); // one three
Remove Items V2:
List myList = new List() { "one", "two", "three" };
// print out the original list
foreach (string item in myList)
Console.WriteLine(item); // one two three
myList = myList.Expect(i => i == "two");
// print out the new list
foreach (string item in myList)
Console.WriteLine(item); // one three
Notes:
The rules for a foreach loop don’t allow you to delete or nullify an object in the collection during the looping, so you need to remove items more directly. For complete objects, this can be a bit harder. Leveraging LINQ can make the task much easier. With the second example, you could use any property/method within the complex object for your comparison. E.G.: IsDirty or ItemFlaggedForDelete().