From the course: Visual Studio Developer Tips

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Randomize data with LINQ

Randomize data with LINQ

- [Instructor] Randomized sampling of data is important in many scenarios. For example, in some cases, it helps cancel the effects of confirmation bias. It can smooth over unintended patterns in the data collection. It's an essential component in most scientific trials. In this tip, I'll look at how to use the LINQ tools in .NET to quickly run a randomized query against the data set. Yes, there are other ways to implement this. For example, with a specialized shuffle algorithm. But this example is quick and easy. For this example, I'm using a WPF application. That way, I can show you a simple bar graph with a randomized data. I've got three charts in this window. The top one, the red one, is bound to the data source and I've done nothing special to it. It's showing the data in the order that is coming from the data source. The orange graph and the blue graph are both bound to the same underlying data source as the red graph, but this time, I'm using the tip to randomize the appearance…

Contents