Monday, August 30, 2010

C++ and OTcl Linkage: Eval — Invoking OTcl statements from the C++ domain

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process, Binding OTcl and C++ ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.
In the previous post, I blogged about an approach to invoke C++ statements from the OTcl domain. This post discuss the reverse: Invoking OTcl statements from the C++ domain.


 

View more presentations from Teerawat Issariyakul.
======================================================
T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from

You may also find lecture notes and other resource at the following website: http://www.ece.ubc.ca/~teerawat/NS2.htm

Friday, August 27, 2010

The Interpretation of Randomness


How much do you know about randomness? What does it mean by a random process? Well, a lot of people would say that a random process is a process whose outcomes cannot be predicted. Clean and simple, and nice for a lot of people.

But this definition is quite vague to mathematician. Mathematicians have something for preciseness. When you say a circle is round, they would ask how round, and you would not know how to reply to them. But if you ask a mathematician how round is a circle, the answer would be 3.14 x R x R where R is the radius.

Likewise, the above definition for a random process is not precise enough. For mathematician, there are at least two interpretation for a random process:

(i) Frequency interpretation: A process is said to be able to generate random numbers when the observed outcome conform to the underlying probability.

(ii) Subjective interpretation: Observed outcomes are said to be random if they cannot be predicted.



Sunday, August 22, 2010

[NS2] Error message: Invalid command

Last week, I've got few messages asking me similar questions. The question was why do I see the following error message when running NS2 and how do I fix it?

invalid command name

Wednesday, August 18, 2010

The Greek, the Roman, and the Mathematics


The Greek and Their Mathematics

Most greek Mathematics are mainly about geometry. They do not believe in probability since
  • They believe that chance is governed purely by Gods.
  • Their number system is very difficult to work with. Algebra and arithematics had not existed in their time. They don’t even have the number zero nor fraction.

Monday, August 16, 2010

C++ and OTcl Linkage: OTcl Commands — Binding OTcl and C++

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction
This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process, Binding OTcl and C++ ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.
In the previous post, I blogged about the key steps in the OTcl domain when instproc or OTcl command is invoked. In this post, I will explain how NS2 moves from OTcl to C++.

Saturday, August 14, 2010

Availability Bias

A Trick Question You Might Want To Try With Your Friends

Let me ask you a question. Among English 6-letter words, which of the following is more probable?
  • Find a word whose fifth letter is ‘n’.
  • Find a word ending with ‘ing’.

Tuesday, August 10, 2010

Regression towards the Mean

A result which falls far from the mean tends to be closer to the mean during the next attempt. Failing something consecutively does not mean that the next attempt will not succeed. Attempts and successes are not linearly related.

Future is unpredictable, but there is one good news. If you are good (i.e., the mean is good enough), you will finally succeed (i.e., reach the mean). Do not give in, even if you have failed (i.e., fall off the mean) consecutively.

“Genius does not guarantee success, but it is seductive to assume that success must come from genius.”

The logic behind the “regression towards the mean” theorem is as follows. Suppose your average test score is 50. Now, let’s take a test. Suppose that you’ve got 40. If your next test scores less than 40, which is further away from the mean, your average won’t be 50. It has to be lower than 50 which contradicts to what we assume at the beginning.


Source: The Drunkard's Walk: How Randomness Rules Our Lives by Leonard Mlodinow, Chapter 1 [Read the Book Review] [Read the Previous Part] [Read the Next Part].

Sunday, August 8, 2010

C++ and OTcl Linkage: OTcl Commands -- Invocation process

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction
This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain [ Getting Started, Invocation process ]
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about OTcl command. I took you to see how to create a OTcl command in C++ and invoke the command from the OTcl domain. how C++ and OTcl classes are bound together. In this post, I will explain the key steps for OTcl command invocation.