Brian Beckman: Hidden Markov Models, Viterbi Algorithm, LINQ, Rx and Higgs Boson
Jan 01, 2012 at 10:21 PMfinally ... cannot wait to see this ... downloading now - enjoying after work ... thank you guys
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
finally ... cannot wait to see this ... downloading now - enjoying after work ... thank you guys
I would really like to play with this but I've got the (known) install problem (c101b00b) - is there any cure for this ill on the way?
Hi - you never have to "foreach" - you can allways use some LINQ-syntax to do the same (and tools like ReSharper even have some automatic code-conversation between the two ways) - it's just a matter of taste and the way the code might look if you use Select/Aggregate/whatever to make it LINQish.
Indeed this might be the indented way - thanks.
But boths of theses seems to me like "breaking the pattern" - if we use a concrete scheduler in the definition of the Observable-Source then what about SubscribeOn (the one with the IScheduler overload)?
What I had expected was something like Create with "Action<ISubscriber>" or something like
public static IObservable<tData> ToObservable<tData>(this IEnumerable<Tuple<DateTimeOffset, tData>> source)
{
/* feed the data (snd) into a IObsevable and use the fst component for the scheduler, whatever it might be */
}
Well - here is my try.
I have to say I've got some problems with this. First it took me a horrible long time to realise that Subject can be used as an Observable-Source you can publish values to. And even worse is the way I have to use the Schedule/OnNext - mess.
Don't know if there is any better way, but why was the way suggested by the video droped?
IObservable<StockQuote> GetQuotes(IScheduler scheduler, IEnumerable<StockQuote> quotes)
{
// Create an observable source of stock quotes
var sub = new Subject<StockQuote>();
foreach (var quote in quotes)
{
var quote1 = quote;
scheduler.Schedule(quote.Date, () => sub.OnNext(quote1));
}
return sub;
}
IObservable<object> Query(IObservable<StockQuote> quotes)
{
// Write a query to grab the Microsoft "MSFT" stock quotes and output the closing price
// HINT: Make sure you include a property in the result which has a type of DateTime
return quotes.Where(q => q.Symbol == "MSFT").Select(q => new {q.Date, q.Close, q.High, q.Low, q.Open});
}
a pitty that nobody posted anything on te challange (or am I missing something?) so here is my *take* on it:
// Convert txt.TextChanged to IObservable<EventPattern<EventArgs>> and assign it to textChanged.
var textChanged =
Observable
.FromEventPattern(addHandler: evHandler => txt.TextChanged += evHandler,
removeHandler: evHandler => txt.TextChanged -= evHandler)
.Select(ev => ((TextBox) ev.Sender).Text)
.Throttle(TimeSpan.FromMilliseconds(300));
// Convert BeginMatch/EndMatch to Func<string, IObservable<DictionaryWord[]>> and assign it to getSuggestions.
var getSuggestions = Observable.FromAsyncPattern<string, DictionaryWord[]>(begin: BeginMatch, end: EndMatch);
var results = from text in textChanged
where text.Length >= 3
from suggestions in getSuggestions(text)
select suggestions;
As you might see I took the freedom to change some little pieces.
First I want to get the text from textChanged (just like in the cast) and second I don't want to fire 7 webrequests in succesion to get the suggestions for "automobile" while typing, so I throttle the textChanged-Observable to 300ms.
Silverlight/WPF. Never made it. Microsoft should just come to terms with this and push HTML5. End of story.
Yeah HTML5 for desktop ... nice ... man go dig yourself some grave
Really nice one - thanks a lot.
Just one think bothers me: Dave positioning needs to be changed ![]()
Hi,
really love the series so far.
I still hope for typeclasses in the CLR ![]()
Nice.
Would be even better if
- it would use F#
- F# would give us Type-Classes
So PLEASE give us Type-Classes for the next release of F# - I guess it would have to be implemented into the CLR but after all we got generics, extension-methods etc. only for LINQ - so why not give us some nice functional sugar ? ![]()