In simpler Markov models (like a Markov chain), the state is directly visible to the observer, and therefore the state transition probabilities are the only parameters. In a *hidden* Markov model, the state is not directly visible, but the output, dependent on the state, is visible. Each state has a probability distribution over the possible output tokens. Therefore, the sequence of tokens generated by an HMM gives some information about the sequence of states. The adjective ‘hidden’ refers to the state sequence through which the model passes, not to the parameters of the model; the model is still referred to as a ‘hidden’ Markov model even if these parameters are known exactly.

Example:

Consider two friends, Alice and Bob, who live far apart from each other and who talk together daily over the telephone about what they did that day. Bob is only interested in three activities: walking in the park, shopping, and cleaning his apartment. The choice of what to do is determined exclusively by the weather on a given day. Alice has no definite information about the weather where Bob lives, but she knows general trends. Based on what Bob tells her he did each day, Alice tries to guess what the weather must have been like.

states = ('Rainy', 'Sunny') observations = ('walk', 'shop', 'clean') start_probability = {'Rainy': 0.6, 'Sunny': 0.4} transition_probability = { 'Rainy': {'Rainy': 0.7, 'Sunny': 0.3} 'Sunny': {'Rainy': 0.4, 'Sunny': 0.6} } emission_probability = { 'Rainy': {'walk': 0.1, 'shop': 0.4, 'clean': 0.5} 'Sunny': {'walk': 0.6, 'shop': 0.3, 'clean': 0.1} }

Implementation in Python:

References:

hmmlearn

wikipedia

]]>

In the terminal window of Pycharm type: source activate [environment-name]

Then you can pip install the package info your environment

The end.

]]>

]]>

**Basic definition:**

T(n) = aT(n/b) + f(n^{c}) **where** a >= 1, b > 1, and c >= 1

T(n) = Θ(n^{c}) **if** c >= log_{b}a

T(n) = Θ(n^{c} log n) **if **c = log_{b}a

T(n) = Θ(n^{logba}) **if** c < log_{b}a

We can think of “b” as the number of branches and “a” as the number of recurrences done; lets take a look at the example.

**If we have a function:**

T(n) = 2T(n/1) + f(n^{0}) : a = 1, b = 2, c = 0

log_{2}1 = 0 **therefore** c = log_{b}a which satisfies Θ(n^{c}log n) = O(log n)

**References:**

anupcowkur.com

wikipedia.com

]]>

Monads allow you to do things like method chaining, and flattening null and exception checks in highly nested code blocks.

**Monadic Rules:**

1. Left identity

Identity.Compose(f) = f

2. Right identity

f.Compose(Identity) = f

3. Associative

f.Compose(g.Compose(h)) = (f.Compose(g)).Compose(h)

**Example: **Very basic Monad to factor out division by zero check in BMI calculation.

Monads are awesome, and I still have a lot to learn about them, however I can already see them everywhere in C#: IEnumerable, JQuery: Ajax Requests and lots more.

Until next time keep learning

**References****:**

blogs.msn.com

wikipedia.org

]]>

For many years MATLAB has been my primary tool for prototyping algorithms, because of its rich set of optimization functions and the AI tool box it has proven to be a valuable tool to have. However, It is not cheap and if you do not have a company to pay for license or attend a university that provides you with a license then you will have to find an alternative.

MATLAB is not a programming language rather its a tool that has as part of its framework a programming language called M language, this language has a lot of quirks and takes some getting use to, the other issue I found with MATLAB is that the functions while well documented do not seem to follow a standard in terms of parameters; on the whole while MATLAB is a good tool for prototyping and is used a lot in engineering and medical fields which are my core domain; However,I am forced to look for a cheaper/free alternative that will give me as much if not more tools than MATLAB now provides.

**Python to the rescue:**

Python is powerful… and fast;

plays well with others;

runs everywhere;

is friendly & easy to learn;

is Open

All these wonderful things make Python a big contender for my MATLAB replacement.

The first thing we want to do is install Python.

Next install my favurite Python IDE PyCharm

Create a new Python Project using PyCharm

**How do we add packages to our project?**

Python is nothing without its packages and two of my favourites are numpy and scipy. To add these packages simply download the Anaconda distribution and configure it to be your default python implementation.

And here is my first piece of python code as taken from the python website

All I need now is a good Python book and 2-4 months to delve into the language. Stay tuned for more posts on my Python journey. Happy coding!!

]]>

svn list -R [your svn repo url] | select-string [string to search for]

]]>

]]>

After installing LINQPad and NUnit Lite open an instance of LINQPad and change the language to C# Program.

Next hit the F4 key on you keyboard to bring up the additional references dialog and browse to the location where you installed NUnit Lite. You will need to add NUnit Lite as a reference.

Copy preceding code into the LINQPad edit window then hit the run button, the results of the test will be displayed in the console window, enjoy

]]>

]]>