Monthly Archives: December 2014

Grouping boxplot in matlab

Here an example from http://stackoverflow.com/questions/16267440/grouping-boxplot-matlab. The example is about on how to create a boxplot for multiple group of variables. The example as follows:

x=rand(1000,6); %variable x
y=rand(1000,6); %variable y
D(:,1:2:12)=x; %rearrange x into d.
D(:,2:2:12)=y; %rearrange y into d

% first column of D, will fill with column of x, then second... 
% column of D will fill with 1st column of y. then the sequent... 
% will follow.

and

figure('color',[1,1,1]); %create a blank graph
boxplot(D,'factorgap',10,'color','rk') %make a box plot on those blank graph
axis([0 25 -1 5]) %not compulsory:rearrange back axis 

set(gca,'xtick',1.8:4.3:50) %put xtick to x-axis
set(gca,'ytick',0:10) %put tick to y-axis
set(gca,'xticklabel',{'Direct care','Housekeeping','Mealtimes','Medication','Miscellaneous','Personal care'}) %label to each x-axis

ylabel('Normalised Y');
 legend(findobj(gca,'Tag','Box'),'HBN04-01 multibed','YAB single ') %put legend to figure

Multiple into one columns and vice versa in Excel using macro

If you work with a lot of data in Excel, it is difficult to rearrange multiple column of data into a single column. The traditional way, you cut/copy and paste, and it will take forever (boring and repetitive works). The simple way, you able to used “macro”. Below are codes for macro in Excel for rearrange multiple columns into one and vice versa, respectively.

Multiple into one columns (Ozgrid.com, 2007):

Sub Multiple_Single()
Dim k As Integer
Dim R As Integer

    k = 2
    R = 0

    Columns("A:A").Insert Shift:=xlToRight

    Do Until R > 65536 Or Cells(65536, k).End(xlUp).Value = ""   
        R = R + Range(Cells(1, k), Cells(65536, k).End(xlUp)).Rows.Count
        Range(Cells(1, k), Cells(65536, k).End(xlUp)).Copy Range("A65536").End(xlUp).Offset(1, 0)
        k = k + 1
    Loop
End Sub

One into multiple columns:

Sub Single_Multiple()
    Dim rng As Range
    Dim iCols As Integer
    Dim lRows As Long
    Dim iCol As Integer
    Dim lRow As Long
    Dim lRowSource As Long
    Dim x As Long
    Dim wks As Worksheet

    Set rng = Application.InputBox _
      (prompt:="Select the range to convert", _
      Type:=8)
    iCols = InputBox("How many columns do you want?")
    lRowSource = rng.Rows.Count
    lRows = lRowSource / iCols
    If lRows * iCols <> lRowSource Then lRows = lRows + 1

    Set wks = Worksheets.Add
    lRow = 1
    x = 1
    For iCol = 1 To iCols
        Do While x <= lRows And lRow <= lRowSource
            Cells(x, iCol) = rng.Cells(lRow, 1)
            x = x + 1
            lRow = lRow + 1
        Loop
        x = 1
    Next
End Sub

References

  1. Ozgrid.com, (2007). Move Multiple Columns From Multiple Worksheets Into 1 Column. [online] Available at: http://www.ozgrid.com/forum/showthread.php?t=75449 [Accessed 17 Dec. 2014].

Monte Carlo Simulation 1 (Bookmark & Planning)

Fig. 1: Try and keep trying. Dont give up

Monte-Carlo, is very famous nowadays. If you work with uncertainty analysis, you will become familiar with this term. From my knowledge (maybe I wrong), Monte-Carlo can be related as sampling method: same like bootstrapping or random generation. Since my study related with climate change, uncertainty became a dominant topic. I very confuse, with this topic and currently, I try to understand and applied it to my study. In this post, I find and collect all possible links and references in which related to Monte-Carlo simulation. In the end, I will summaries those collections into a new post, entitled Monte Carlo Simulation 2. Please wait for the future post.

Bookmarks:

  • http://blog.minitab.com/blog/understanding-statistics/monte-carlo-is-not-as-difficult-as-you-think
  • http://www.minitab.com/en-us/Published-Articles/Doing-Monte-Carlo-Simulation-in-Minitab-Statistical-Software/