The post C# Math: coefficient of variation appeared first on Martijn Kooij.

]]>The coefficient of variation (CV) is a normalized measure of dispersion. It is a measure of consistency indicating the uniformity in the values of the signal from the mean of the signal. A smaller coefficient of variation indicates a more consistent signal. The values are more uniformly dispersed.

Coefficient of variation is useful when comparing data with different units. For example in the SoapSynergy project I am working on I often have to make comparisons between displacement and angles. Since those signals have different units ((centi)meters versus degrees) it is useful to have a dimensionless number to compare with.

The downside of the coefficient of variation is that it is quite sensitive to changes in the mean. So if your signal moves around the 0 (as a sine wave does) making your mean ~=0, the coefficient of variation can quickly jump to near infinite numbers rendering it useless. For this reason I chose to calculate the coefficient of variation using the absolute values of my signals.

using System; using System.Collections.Generic; namespace SampleApp { internal static class Program { private const float CompareIsZeroTolerance = 0.000000000001f; private static void Main() { List<double> data = new List<double> {1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2}; double mean = data.Mean(); double sd = data.StandardDeviation(); double cv = CoefficientOfVariance(sd, mean); Console.WriteLine("CV: {0}, (mean: {1}, sd: {2})", cv, mean, sd); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } private static double CoefficientOfVariance(double sd, double mean) { if (Math.Abs(mean - 0) < CompareIsZeroTolerance) return 0; return sd / mean; } } public static class MyListExtensions { public static double Mean(this List<double> values) { return values.Count == 0 ? 0 : values.Mean(0, values.Count); } private static double Mean(this IList<double> values, int start, int end) { double s = 0; for (int i = start; i < end; i++) { s += values[i]; } return s / (end - start); } private static double Variance(this IList<double> values, double mean, int start, int end) { double variance = 0; int i; for (i = start; i < end; i++) { variance += Math.Pow((values[i] - mean), 2); } int n = end - start; if (start > 0) n -= 1; return variance / (n); } public static double StandardDeviation(this List<double> values) { return values.Count == 0 ? 0 : values.StandardDeviation(0, values.Count); } private static double StandardDeviation(this IList<double> values, int start, int end) { double mean = values.Mean(start, end); double variance = values.Variance(mean, start, end); return Math.Sqrt(variance); } } }

The post C# Math: coefficient of variation appeared first on Martijn Kooij.

]]>The post Duplicate movies in XBMC appeared first on Martijn Kooij.

]]>Well, I am glad I can now say I found what was causing the duplicate movies in XBMC for me. There were plenty of Google search results on the topic, but none of them seemed to apply to my situation. In the end it, of course, turned out to be much simpler than all those issues shown to me in Google. So simple as well as specific that I might just as well be the only one ever experiencing this. A you ready for it?

In my case, the duplicate movies in XBMC were caused by the infamous hidden **._** files OS X loves to generate every now and then. As said my XBMC runs on OpenELEC on my htpc, and every now and then I need to copy a movie or show from my Mac to the htpc. I’m still not entirely sure when it does and when it does not happen, but that copy will at times come with a free extra “._” duplicate of the file which is around 4K in size. The reason is something about different file systems and certain meta information (resource forks called AppleDouble) OS X thinks it absolutely has to copy along, but since the other file system does not support that meta information, it creates the extra file… Blabla… Just as annoying as the .DS_Store files if you ask me.

There are plenty of ways to be found on how to prevent these ._ files from being created, I will leave it to you to pick a method you like. I will only show you how you can fix it once you start noticing duplicate movies in XBMC.

Basically the actions are just to remove the ._ files and then clean your library so XBMC will remove all references to non-existing files.

If you have a keyboard attached to your XBMC than it is probably easiest to just use the file manager and delete the files. But if, like me, you only access your XBMC using a remote app like Constellation it is more convenient to just remove them using the Mac terminal.

Just open up a terminal and navigate to your xbmc share. You can list hidden files using the -a parameter like so:

ls -a

Next just remove all ._ files in that directory:

rm ./._*

Or if you are lazy / confident you can just delete all ._ files on the remote folder recursively:

find . -name '._*' -type f -delete

After all the files are gone just navigate to System/Video and tap “Clean library…” on your XBMC and you should be clean of all duplicates again.

The post Duplicate movies in XBMC appeared first on Martijn Kooij.

]]>The post Very last update of the Grocery List Generator add-on appeared first on Martijn Kooij.

]]>Over the last few days I have received numerous e-mails about the latest Firefox 20.0.1 update (finally) breaking my Grocery List Generator add-on. So that was it I thought, I always expected my extensions to go down one by one, but I always thought they would go just a bit slower. Just losing a feature every now and then, apparently I guessed wrong. The Grocery List Generator simply stopped doing it’s most important thing: Generating a grocery list… And that just did not sit well with me. So call me weak, call it unfair to the users of my other extensions, but I have released one last update for the Grocery List Generator on the GLG website. I will not be releasing it to .

The Grocery List Generator (GLG) is a helpful little tool to store your recipes, ingredients and all the other groceries you need regularly.

It creates a well-organized grocery list grouped by aisle, to help make your grocery shopping as easy as possible. The Grocery List Generator operates as a Firefox add-on and was first released on October 6. 2005 by the original idea of my mate LX and his girlfriend.

If you do not yet use the Grocery List Generator, go to the Install the GLG page and just give it a try. It’s free!

In August 2011 I released the iPhone version of the GLG! Along with all the features and concepts you are all already familiar with the iPhone app also offers lots of brand new features to make your grocery shopping easier than ever before. If you own an iPhone or iPod Touch then don’t waste another minute and, more important, don’t waste another piece of paper on your lists and get the GLG App in the App Store right now!

In November 2011 the new website for the iPhone app was launched. Compact, smart, stylish, just like the iPhone app, Visit the GLG App website

The post Very last update of the Grocery List Generator add-on appeared first on Martijn Kooij.

]]>The post C# Math: Root Mean Square appeared first on Martijn Kooij.

]]>**Root Mean Square**takes the squares of all values and divides them by the number of values. And then taking the square root of that number.

In the code sample I will show the difference by computing the mean and the root mean square of a set of data: -1,0,1,0,-1,0,1. Because of the negatives canceling the positives, the mean will be 0. If you were more interested in the average magnitude of this signal you would use the root mean square and get an rms value of 0.76.

using System; using System.Collections.Generic; namespace SampleApp { internal static class Program { private static void Main() { List<double> data = new List<double> {-1,0,1,0,-1,0,1}; double mean = data.Mean(); double rms = data.RootMeanSquare(); Console.WriteLine("Mean: {0}, RootMeanSquare: {1}", mean, rms); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } } public static class MyListExtensions { public static double Mean(this List<double> values) { return values.Count == 0 ? 0 : values.Mean(0, values.Count); } private static double Mean(this IList<double> values, int start, int end) { double s = 0; for (int i = start; i < end; i++) { s += values[i]; } return s / (end - start); } public static double RootMeanSquare(this List<double> values) { return values.Count == 0 ? 0 : values.RootMeanSquare(0, values.Count); } private static double RootMeanSquare(this IList<double> values, int start, int end) { double s = 0; int i; for (i = start; i < end; i++) { s += values[i] * values[i]; } return Math.Sqrt(s / (end - start)); } } }

The post C# Math: Root Mean Square appeared first on Martijn Kooij.

]]>The post C# Math: Mean, Variance and Standard Deviation appeared first on Martijn Kooij.

]]>- The
**mean**is just the average, the value that is the sum of all values, divided by the number of values. - The
**variance**is a way to measure how far a set of numbers is spread out. The variance is an measure of how much a set of numbers change, how much variation there is in those numbers. - The
**standard deviation**measures how far the values in a set are spread out from the average, just as the variance does. But since the SD (standard deviation) uses the same units as the mean it is easier to interpret.

Now to show you a quick code implementation of these 3 routines using c# math. Since I required means of n samples of data as well I used overloaded methods to support computation of the entire set as well as subsets. These methods also show the concept of extension methods in c#, in this case extending the default set of a generic list of doubles.

using System; using System.Collections.Generic; namespace SampleApp { internal class Program { private static void Main() { List<double> data = new List<double> {1, 2, 3, 4, 5, 6}; double mean = data.Mean(); double variance = data.Variance(); double sd = data.StandardDeviation(); Console.WriteLine("Mean: {0}, Variance: {1}, SD: {2}", mean, variance, sd); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); } } public static class MyListExtensions { public static double Mean(this List<double> values) { return values.Count == 0 ? 0 : values.Mean(0, values.Count); } public static double Mean(this List<double> values, int start, int end) { double s = 0; for (int i = start; i < end; i++) { s += values[i]; } return s / (end - start); } public static double Variance(this List<double> values) { return values.Variance(values.Mean(), 0, values.Count); } public static double Variance(this List<double> values, double mean) { return values.Variance(mean, 0, values.Count); } public static double Variance(this List<double> values, double mean, int start, int end) { double variance = 0; for (int i = start; i < end; i++) { variance += Math.Pow((values[i] - mean), 2); } int n = end - start; if (start > 0) n -= 1; return variance / (n); } public static double StandardDeviation(this List<double> values) { return values.Count == 0 ? 0 : values.StandardDeviation(0, values.Count); } public static double StandardDeviation(this List<double> values, int start, int end) { double mean = values.Mean(start, end); double variance = values.Variance(mean, start, end); return Math.Sqrt(variance); } } }

The post C# Math: Mean, Variance and Standard Deviation appeared first on Martijn Kooij.

]]>The post OpenELEC 3.0.0 released appeared first on Martijn Kooij.

]]>The most notable changes from the 1658 (!) changes in total are:

- DTS-MA and Dolby True-HD via XBMC’s new AudioEngine (requires hardware support, and not possible on AMD and RPi/ATV)
- Greatly improved Live TV and PVR support
- Improved image support, allowing the database to use additional image types.
- Support for the Raspberry Pi
- Better Airplay support across all platforms
- Advanced Filtering in the library
- Advanced UPnP sharing

Updating is a breeze, just download and unpack the build of your choice, and copy the 4 (KERNEL, KERNEL.md5, SYSTEM and SYSTEM.md5) system files to the /updates folder on your OpenELEC share. Detailed instructions are available on the OpenELEC wiki.

Original source OpenELEC news

The post OpenELEC 3.0.0 released appeared first on Martijn Kooij.

]]>The post New website live appeared first on Martijn Kooij.

]]>The post New website live appeared first on Martijn Kooij.

]]>The post End of life for my Firefox extensions appeared first on Martijn Kooij.

]]>I have had the best time developing new things and working closely with the Mozilla community to improve my 10 (!) extensions. But it has been well over 7 years now and it is time for something new. Most of you had already noticed that I was already slowing down on development, and even officially stopped support on some of my extensions. But even inactively maintaining my current 6 extensions is sort of holding me back from really going forward and start doing new things. So it’s time to start shutting things down. Extensions you have currently installed will keep on working as long as Firefox does not change too much. But services around my extension such as my forum or the Web Search Pro search engines pages will be closed sometime in the near future (within a year or so). For Web Search Pro users, mycroft has a huge amount of search engines for you and wont likely close.

In case someone is interested, either from loving my work or purely from a business point of view, in taking over my work you can mail me at extensions[at]captaincaveman.nl. I have made the statistics of all of my extensions on AMO publicly so you can assess what you will be getting yourself into, or to get an estimate of possible revenue. Small note on those statistics is that they have of course all dropped quite a bit, not actively developing new things and releasing updates does that to your download statistics.

Well, I guess that’s it for now, and perhaps forever. I would like to thank all of you for 7 years of kindness and huge appreciation for the things I made, nowhere else have I ever seen a community so kind and close connected to the developers of the open source stuff they wanted.

Love you guys!

Cheers.

Martijn

The post End of life for my Firefox extensions appeared first on Martijn Kooij.

]]>The post Grocery List Generator for iPhone and iPad updated appeared first on Martijn Kooij.

]]>What’s New in Version 1.2

New features

– Full iPad support.

– Share a recipe with friends using email, Twitter or link- Send your grocery list to a friend.

– Friends can add your recipe or grocery list to their GLG app.

– Merge two aisles into one to easily combine all their items.

Bug fixes

– The recipe search tool also checks the recipe description.

– All screens switch between portrait and landscape orientation.

– The recipes tab is fitted with an index.

– Focus is automatically set to aisle name in the aisle’s detail screen.

The post Grocery List Generator for iPhone and iPad updated appeared first on Martijn Kooij.

]]>The post GLG iPhone app website launched appeared first on Martijn Kooij.

]]>The post GLG iPhone app website launched appeared first on Martijn Kooij.

]]>