Monday, 21 May 2018

Theory of Estimation: Unbiased Estimation

I was happy to see that Estimation was really an easy topic to understand, easier than I always thought.
In this  article, I would teach you in very simple way, the theory of estimation and you would understand it very clearly.

The challenge many have sometimes is caused by lecturers not explaining the concept clear enough, especially from the basics.


1. Basics: What is Estimation?

Estimation is the process involved in systematically inferring the hidden or unobserved variable from a given information set using a mathematical mapping between the unkowns and the knowns as well as a criterion for estimation.

To carry out estimation you need the following:
  • Data: Set of data
  • Estimator: The estimator takes in the data as well as two more items (Objective Function and Model) and then helps us make an estimate.
  • Model: This is a mapping between the knowns(your dataset) and the unknowns (the parameter)
  • Objective Function: This is a mathematical statement the can be mimimized or maximized to find best possible solutions among a set of solutions.

2. Basic Concepts of Estimation

Take note of these three basic concepts

The theory of estimation provides the following to help us in the task of making estimation:
  • Method for estimating the unknowns (eg. model parameters)
  • Means for accessing the 'goodness' of the resulting estimates
  • Making confident statements about the true values (how sure we are about the estimate)

3. Unbiased Estimator

A statistic could be defined as an unbiased estimate of a given parameter if the mean of hte sampling distribution of that statistic can be proved to be equal to the parameter being estimated.

Unbiasedness means, that for a large number of observations(samples), the average over all estimations lies close to the true parameter.

4. Sample Mean Example

Given an n-dimensional vector, X1, . . . ,Xn, prove that the extimator for the means μ is unbiased.

To estimate the mean, we use the sample mean as an estimator.

We now prove that the expected value of the estimator is equal to the true mean μ (condition for unbiasedness). This we would do using the linearity of the expected value
From the above, we can conclude that the estimator
is an unbiased estimator of the sample mean. Thank you for your effort in learning. You can reach me if you find anything difficult.

We consider more examples in the following parts.

Sunday, 20 May 2018

How to Display Logged In User Details Using AngularJS

Hey! Good to see you!

Let's keep it simple this time. I would just give you:
  • the HTML code
  • the AngularJS Script

We would like to display the users Firstname, Lastname, email and Department

Then I would tell you the files you need to  include in your header.

File to Include in your Header
You need to include Bootstrap, JQuery and AngularJS in the header section of your html page

<script type="application/javascript" src="jquery.min.js"></script>  
<script type="text/javascript" src="bootstrap.js"> </script> 
<script type="application/javascript" src="angular.js"></script>
Listing 1: Header Files

AngularJS Script
The AngularJS script is given below. You need to enclose it in a <script></script>

var ShowUser = function(){
  url: baseUrl + "api/user",  //The Base URL depends on your sharepoint server
  method: "GET",
  headers: { "Accept": "application/json; odata=verbose" }
  }).then(function mySucces(response) {
   $scope.DisplayName = + ', ' +;
   $scope.Location =;
   $scope.Department =;
   $scope.TotalPoints = 280;

 }, function error(response)  {
Listing 2: AngularJS Script

The script retrieves the user's details from a the Request URL. Then it places the retrieved data in the $Scope variable. Data placed in the $Scope is accessible from the html page by using the {{}}  to enclose the variable name. That's all you need

The HTML Code
The HTML section that displays the  user details is given below. You can modify it to fit your page design.
 <li>{{Department}} </li>
Listing 3: HTML Code

Make sure you try it and let me know if you have any challenges.
Thanks .

Wednesday, 16 May 2018

How to Post Data to a SharePoint List with AngularJS - Easy Steps

Hello, good to see you here.
Be sure that it really is not so difficult to post data from a form to a SharePoint List. I would show you the steps and also give you the codes.
Just 5 Steps. Lets go!


If you have any issue though, just let me know. Use the comment box below or the form to left of this page.

Step 1: Create a SharePoint List 

Create a list in SharePoint and called CustomerDetails.
This list should contain the following fields three fields.
  • Firstname
  • Lastname
  • Address
We are keeping it very simple so you will understand exactly how it works.

Step 2: Add Bootstrap, AngularJS and JQuery

Create a html page and add AngularJS and BootStrap to the header like shown below:


<title>AngularJS Tutorial</title>
<script type="text/javascript" src="bootstrap.js"> </script>
<script type="application/javascript" src="jquery.min.js"></script>
<script type="application/javascript" src="angular.js"></script>
<script type="application/javascript" src="index.js"></script>


//We would place the form here

Listing 1: Add files in header section

Step 3: Add the html Form

Add the following html to the body of your page, in between the <body> and </body> tags. This is the form that would be filled to be submitted to the SharePoint list

<form name="userForm" ng-app="myapp" ng-controller="myController" >
  <div class="form-group">
 <label for="firstname">Firstname </label> 
 <input type="text" ng-model="Firstname" class="form-control" id="firstname" />    
  <div class="form-group">
 <label for="lastname">Lastname:</label>
 <input type="text" ng-model="Lastname" class="form-control" id="lastname" />
  <div class="form-group">
 <label for="address">Address:</label>
 <input type="text" ng-model="Address" class="form-control" id="address" />
  <button type="submit" class="btn btn-primary"  ng-click="submitCustomer()" class="btn btn-default" data-dismiss="modal">Submit</button>
Listing 2: Code the HTML Form

Step 4: Add the Script

Add the following code to your AngularJS script. Name this script index.js. It's a bit complicated but I want you to first try it, then I would explain how it works to you or help you debug any error you may be getting. Remember to link this script to your html page and place the two in the same folder

var myapp = angular.module('myapp', []);

myapp.controller('myController', function($q, $scope, $http){

 //add nomination to start workflow                                                      
 function getRequestDigest(){
   var deferred = $q.defer();   
     $http ({
     url: "RequestDigest url ", //Get this url from your IT department
     method: "POST",
     headers: {
     "Content-Type": "application/json; odata=verbose",
     "Accept": "application/json; odata=verbose"
    }).success(function (response) {
     console.log('X-RequestDigest value:', response.d.GetContextWebInformation.FormDigestValue); 
     $scope.requestDigest = response.d.GetContextWebInformation.FormDigestValue;
    }).error(function (err) {
     console.log('Error in POST request digest', err);
    return deferred.promise;
 //digest end

 function AddCustomer(listName){
    $scope.submitError = false;
    var deferred = $q.defer();
    var requestData;
    var  GetItemTypeForListName = function (name) {
   return "SP.Data." + name.charAt(0).toUpperCase() + name.split(" ").join("").slice(1) + "ListItem";
     var itemType = GetItemTypeForListName(listName);

    requestData = {
    "Title": $scope.Firstname,
    "LastNamePhonetic": $scope.Lastname,
    "WorkAddress": $scope.Address,
  __metadata : { type: itemType }
    var postUrl = baseUrl + "_api/web/lists/getbytitle(listName)/items"; //Replace baseUrl
    var config = {
     headers: {
    "Content-Type": "application/json; odata=verbose",
    'Accept': 'application/json; odata=verbose',
    'X-RequestDigest': $scope.requestDigest
   console.log("requestDigest", $scope.requestDigest);
   $ (postUrl, JSON.stringify(requestData), config).then(function (data) {
      console.log("success", data);
      console.log("failed", error);

   return deferred.promise;


 //button- generate new item in the list and run wf
  $scope.submitCustomer = function (){
    var promise1 = getRequestDigest();
    promise1.then(function(){       //1st run the RequestDigest, then the AddCustomer
 //button end

Listing 3: Content of your index.js file

Step 5: Test your page!

Although it looks complicated, but it is really very simple. Trust me!

Go ahead to view the page.
Enter some items in the form and submit and check that the items gets inserted. Then go the list in SharePoint to make sure the item actually got inserted.

Let me know if you have challenges, I would be able to provide some guidance for you 

Wednesday, 9 May 2018

How to Succeed in Math (5 Secrets of Making Math Very Easy) - By a Genius

Good to see you again! Today's discussion would be Math and I would give you some secrets on how to succeed in Math.

You know, Math have always been and would always be my favorite subject. I learnt it, I practiced it, an I taught it as a teacher some time in the past in secondary school.  

So what I'm going to tell you are actually secrets, if you don't know these five points then you will always likely hate Math. An believe me, Math is actually the most interesting subject.

In this post, I would like to let you know how to succeed in study of Mathematics. I would be talking to you based on my own personal experience.

Point 1: Spend all the Time on it
Assuming that you have been having a particular course, every semester for three years
  • MTH 101 - Introduction to Elementary Math
If on the first semester of the fouth year, you have 6 courses with the same Math course included (that is the 7th time you are having this same course), that is Introduction to Mathmatics(MTH 101). 

The question now is: How easy would this course be at this time? 

You guess right?

I tell you, this MTH 101 would be the easiest course for that semester. The reason is that, you've spend so much time on a studying Math over the months, therefore it would be the easiest compared to other courses that are totally new. This is in the sense that it would be less difficult.
Whats the Point: The point is that the more the percentage of your time you spend in studying Math at the expense of time that would have been used for other causes, the easier Math becomes compared to  those other courses.
This nails the first point.

Spend plenty of time studying Math and you will find out that other courses becomes more difficult(meaning that Math becomes easier!). Even if it appears not interesting, just spend time on it.

I'm sure you get the point now. Let's move to the the second point.

Point 2: Get a Good(Possibly the Best Textbook)
No matter how anyone may choose to see it, a good textbook would always help you enjoy the study of Math. And the more you enjoy studying Math, the easier it becomes. So don't just settle with the recommend textbooks in school. Go out there to get the bookshops and get one. I found out from experience that textbooks written by Americans are always very good when it comes to study of Math. An example is K.A Stroud Engineering Mathematics. If you are in University, no matter the faculty or department, once there is Math in your curriculum, buy Engineering Mathematics.

Point 3: The Principle of First Principles
The principle of First Principles in Mathematics states that, "For you to understand a new topic in Mathematics, learn its first principles".

Lets take an example: what do you understand by dy/dx in Calculus?


This is the meaning of dy/dx from the first principle. The basics is that dy/dx is the slope of the graph. From here you can appreciate how the concept of differentiation and integration, that is the two basic topics in calculus. So what is the point. To learn a new topic in Math, go all the way to the first principle, and that you can do by finding the first part of the chapter that discusses the topic and the first principles would likely be explained there.

Point 4: Ask For Help From Math Pros (just like me!)
This is very important. As the saying goes that 'a day with a good teacher is better than a thousand days spend reading a book'. This is so true in the case of Mathematics. So if there is someone you know that is very good in Mathematics, pester on him to teach you, explain solutions to Math problems, explain the concepts to you an so on. Fortunately, Kindson the Math Pro is there for you. So just paste the Math exercises on the comment box below and I would get back to you.

Point 5: Solve and Solve and Solve!
Get as many examples and exercises as possible. Just keep solving. For textbooks that have solved examples, try to solve it yourself first and then compare your own solution with the example in the textbook. For the exercises, solve all if you can and then verify if your answer is correct.

I assure you that I you apply this five points, you will make so much improvement in Math and with time you will find Math very interesting. Trust me!

I will stop here for now, and I would like to thank you for reading. If this have been informative for your tell me how you feel in the comment box below and Follow me on Google+. 

You can as wells subscribe to my YouTube channel at Kindson The Math Pro on YouTube

Monday, 30 April 2018

How to Add a Progressbar Column to Table Using AngularJS and BootStrap UI

Hello, my friend. I'm Kindson, and good to see you here!

In this tutorial, we are going to learn how to add a progresss bar column to HTML table using AngularJS
  1. Introduction
  2. About AngularJS
  3. What you Need
  4. How it works
  5. How to Vary Color Based on Value
  6. Final Notes

1. Introduction

By now you should know how to display tabular data using AnuglarJS. If not you can look at this lesson: Display SharePoing Table Using AngularJS
Remember you can reach me if you have challenges.

Sometime you may need to display percentages in a progress bar in a table column. Or it may be number of points a user have accumulated in membership website. Using a progressbar would make it more interesting for your users.

2. About AngularJS

AngularJS is a very easy to use framework that helps you to create dynamic page that integrates data into your html page using AngularJS markup.
All you need to to is to add the link to the js file in the head tag of your page.

3. What You Need

  • BootStrap
  • JQuery
  • AngularJS

4. How it Works

It works in a very simple way.
The lenght of the progress bar is defined by the values in another column of the table. So basically, any table that have a column containing number can be used to display a progressbar.
The code is shown in Listing 1.0.

<table border="1" class="em-c-table">
    <thead class="em-c-table__header">
        <tr >
    <tbody class="em-c-table__body">
        <tr ng-repeat="row in data">
            <td><div class="progress progress-striped">
      <div class="progress progress-bar-warning" ng-style="{width: row.Percentage+'%'}"> {{row.Percentage}}</div>
Listing 1.0: HTML Table Structure

The progressbar is displayed in the third column of the table
 Note there are two div tags and one ng-style attribute
  • The first div tag sets the type of progressbar:  "progress progress-stripped
  • The second div tag sets the  color: "progress progress-bar-warning"
  • The ng-style is used to set the width of the bar to the value of the Percentage field in the table.
I hope this is clear. But if not, leave me a comment. I would explain more clearly to you.

5. How to Change Color Based on Value

You may want to vary the color of the bar depending on the value of the lenght. For example:
0 - 60: green
61 - 90: orange
91 - 99: red

To achieve this, you simply need to add a simple class to the <td> tag.

ng-class="{'progress-bar-danger': percent<33, 'progress-bar-info': percent>=33 && percent<66, 'progress-bar-success': percent>=66}"

6. Final Notes

Make sure you try it yourself. Just copy the code to your IDE and try to modify it to fit your data and then make sure it works.
If you completed this tutorial, thumbs up to you!. If you have any challenges, let me know in the comment box below or to the left of this page.

Tuesday, 24 April 2018

Add Pagination to a Page Using AngularJS and BootStrap

In this tutorial, I am going to teach you an easy way to add pagination to a html page using AngularJS and Bootstrap. Trust me, this would be very easy!

I would also share my code freely with you. So you can copy and use, though it took my some days to figure out and put it together.

  1. Background
  2. Scripts and CSS to Include
  3. Script that Handles Pagination
  4. The HTML Page
  5. Final Notes


We would use a dataset from SharePoint list retrieved using AngularJS.
The list is named users with two fields Name and Points

2. Scrips and CSS to Include

Place the following 4 scripts and on css file in the head tag of your html file. These are all the scripts you need for pagination.

  <script type="application/javascript" src="js/angular.1.6.2.js"></script>
  <script type="application/javascript" src="js/angular-route.1.6.2.js"></script>
  <script type="application/javascript" src="js/jquery-3.2.1.js"></script>
  <script src="//"></script>

  <link href="//" rel="stylesheet">
Listing 1.0: Scripts and Css for AngularJS and BootStrap

3. Script That Handles Pagination

You then need to write the script that handles the pagination.
In the script below, there is a function called GetListItems(). You need to write this script yourself as this is not the focus of this lesson. Just know that this script returns the data we would need to paginate.
(If you want the whole code, let me know in the comment box below or to the left of this page)

        var appVar = angular.module('plunker', ['ui.bootstrap']);

        appVar.controller("controller1", function($scope){    
            GetListItems($scope, "Users"); //Uses the $.ajax to retrieve data from sharepoint and place it in the scope
            $scope.viewby = 10;
            $scope.totalItems = $;
            $scope.currentPage = 4;
            $scope.itemsPerPage = $scope.viewby;
            $scope.maxSize = 5; //Number of pager buttons to show
            $scope.setPage = function (pageNo) {
            $scope.currentPage = pageNo;
            $scope.pageChanged = function() {
            console.log('Page changed to: ' + $scope.currentPage);
            $scope.setItemsPerPage = function(num) {
            $scope.itemsPerPage = num;
            $scope.currentPage = 1; //reset to first page
Listing 1.1: Script that Handles Pagination

4. The HTML Page

Now lets see how your table would look like in the html page.

<div ng-app="plunker">    
    <div id="App1" ng-controller="controller1">    
        <h1>List of Items Being Paginated Final</h1>    
        <table border="1">
            <tr >
        <tr ng-repeat="row in data.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage)) | orderBy : '-Percentage'">
        <select ng-model="viewby" ng-change="setItemsPerPage(viewby)">
        </select> records at a time.
    <pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()" class="pagination-sm" items-per-page="itemsPerPage"></pagination>
    <pre>The selected page no: {{currentPage}}</pre>
Listing 1.2: HTML Page With Table Markup

The Table is quite simple, contains only two columns, Name and Points.
The code includes a dropdownlist (Select list) to display numbers that the user can select.. Selecting any of the numbers filters the list and displays that number of items in the table

5. Final Notes

I sincerely hope that these lesson helps you to achieve pagination in your page. I do thing it is quite simple provided you already have a knowlede of HTML, AngularJS and JavaScript.
However, if you have any difficulties, just let me know in the comment box below or to the left of this page, so I could speak with you over skype and guide you.

Welldone, my programmer!

Monday, 23 April 2018

How to Fetch SharePoint List using AngularJS and Display on html Page (Explaining the Codes)

Hello, good to see you again.
I am Kindson and today, I'm going to explain to you how to fetch Sharepoint using AngularJS list and display it in html page. I would try to be very clear and easy to follow in this lesson.
So Let's go!

  1. Introduction
  2. The Building Blocks You Need
  3. Understanding the Pieces of the Your Script
    • Initializing the AngularJS App and Controller
    • The GetList() Function
    • The $.ajax() Method
    • Success Function
    • Error Function
  4. Understanding the Pieces of the your html page
    1. The ng-app directive
    2. The ng-controller directive
    3. The ng-repeat directive
    4. Specifying Repeat Items
  5. Final Notes

1. Introduction

In this simple tutorial, you I explain very clearly and in a simple way the ingredients you need to query a SharePoint list and display the content on a html page.
Note that we can perform SELECT, INSERT, UPDATE and DELETE operations on a SharePoint list using AngularJS. In this lesson, we would examine the select operation and in the following lessons we would learn about the other CRUD operations.
How it works is that AngulaJS makes a REST GET request to the SharePoint list and gets a JSON response. It then parses this response and displays it on a page.
Easy? Right? Let's see! ☺

2. Building Block you Need

1. You Need two  AngularJS files: the angular.js file and the angular-route.js file
2. A html Page to display your results
3. The Script code we would write. In this case, we would include the script in the html file using the <script></script tag. But for very large scripts, a seperate file would be needed

3. Understanding the Pieces of the Your Script

Let's start writting the script and as we write, we would be explaining each piece of the script. So now, create a html file  with the basic content:

<script type="text/javascript" src="angular.1.6.2.js"></script>
<script type="text/javascript" src="angular-route.1.6.2.js"></script>
<title> Fetch HTML List Using AngularJS</title>


AngularJS Code goes here

AngularJS+HTML is used to diaplay list of items in tabular form
Listing 1.0: How AngularJS works in HTML page

From the html file, we would write our AngularJS codes inside the <script></script> part.
The we would  write the html codes inside the <table></table> tag to display the data.

Initializing the AngularJS App and Controller

Write this code inside the script block

        var appVar = angular.module('listApp', ['ngRoute']);
        appVar.controller("controller1", function($scope){    
        GetListItems($scope, "Users");            
Listing 1.1: Initializing AngularJS App and Controller

The first line initializes and AngularJS app called appVar. This is done using angular.module method. This method takes the name of the app (you can choose any name) and a second parameter ['ngRoute']

The second parameter ngRoute according to W3school 'allows you to navigate to different pages in your application, while the application remains a single page application(SPA) with no page reloading.

The GetList() Function
This function could have any name.
It is the function that contains the code that actually performs the query to fetch data from the SharePoint list.

I have added line numbers to the code below, for easy explanation

     function GetList($scope, listName){    
            var requestUrl = "sites/KindsonTheGenuis/Lessons/2018/_api/web/lists/getbytitle('" + listName + "')/items";           
            url: requestUrl,    
            method: "GET",    
            async: false,    
            headers: { "Accept": "application/json;odata=verbose" },    
            success: function(data){    
                $scope.items = data.d.results;    
            error: function(sender,args){    
Listing 1.2: AngularJS code to make GET Request to a URL

The function GetList in line 1 takes two parameters. The first parameter is $scope. This parameters makes is possible for  objects declared in the controller code to be available for use in the html page.
The second parameter listName is the name of the SharePoint list you want to access.

The $.ajax() Method
The $.ajax() method is used to  create ajax request.
It takes the following parameter:
url: a string value of the request url to send the request to
async: indicates if wether the request should be
method: specified the HTML method to use for the request. Here we use a GET methods since we are only retrieving data
headers: specifies the headers  such as contenttype

The next two parameters are functions discussed next

Success Function 
This is a function that is run if the request is successfully  executed. In this case, the fuction takes the results of the request and assigns it to the items collection of the $scope object. This makes is possible that the results are available in the view(html page)

Error Function
This is the fuction that is run if the request fails. In this case a message containing the error is written to the console.

4. Understanding the Pieces of the your html page

The page displays the data from the request. So how does this work?
Remember that the data from the request was put in $scope.items. This means that it  can be accessed from the html page.

<div ng-app="listApp">    
    <div id="App1" ng-controller="controller1">    
        <h1>First List Items</h1>    
        <table border="1">
        <tr ng-repeat="item in items">
Listing 1.3: HTML Page displaying AngularJS Content

The ng-app directive
This helps you to specify the root element of the AngularJs application. All AngularJS application must have a root element in the html page.
If this code is specified in a html element, then AngularJS code could be written inside this element. In our case we made the table element the root element. But you can also place this code in the body element of the html code.

<table ng-app='modulename'>
AngularJS code can go here...
modulename specifiess the name of the module to load with the application. Remember that the modulename is given as parameter to the angular.module() method.

Quiz: What is the modulename from our code? ☺

The ng-controller directive
The ng-controller directive attaches a controller to the view(html page).
This means that the functions and variables defined in the controller will be available in the veiw.(remember, our controller is Controller1)

The ngRepeat directive
The ngRepead directive is added to the html page to iterate through a collection of items. Look at the code fragment so you oculd understand how it works.

In our case we have

<tr ng-repeat="item in items">
<td>{{item.Firstname}} </td>
<td>{{item.Lastname}} </td>

Listing 1.4: Using ng-repeat to display a table

This code would create as many rows as there are items in the $scope

Specifying Repeat Items
Repeat items are specified one element below the element containing the ngRepeat directive. So in our case, the ngRepead directive is in <tr> element, therefore, the repeat elements would be in the <td> tag.
Also, the repeat variables are enclosed in double curly braces, like this {{}}

5. Final Notes

If you hav followed this tutorial up to the end, thumbs up to you. If you have any challenges or observation, you can let me know in the comment box below or in the form to the left of this page.

I would also like to let you know that the key to catching up on software tutorials is to practice them yourselft. Secondly, you can get assistance from experienced professionals like me!
Feel free to leave me a message or question

Thanks for your efforts!