CS 424 Big Data Analytics

Session 2: Problem solving

Instructor: Dr. Bob Batzinger
Academic year: 2021/2022
Semester: 1

Begins June 2021

Analytical Exercise

Analysis of Problem A

Analysis of Problem B

\[\begin{matrix} Eq. & Forumula & Origins\\ 1)& 90 = A + a + c + x& Given\\ 2)&80 = B + a + b + x & Given\\ 3)&70 = C + b + c + x & Given\\ 4)&100 = A+B+C+ & \\ & \quad a + b+ c + x & Given \\ 5)&10 = B + C + b & E4 - E1\\ 6)&20 = A + C + c & E5 - E2\\ 7)&30 = A + B + a & E5 - E3\\ \end{matrix}\]

Using Linear Algebra to Solve 7 Equations

\[\begin{pmatrix} 1 & 0 & 0 & 1 & 0 & 1 & 1 \\ 0 & 1 & 0 & 1 & 1 & 0 & 1 \\ 0 & 0 & 1 & 0 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 1 & 0 & 1 & 0 & 0 \\ 1 & 0 & 1 & 0 & 0 & 1 & 0 \\ 1 & 1 & 0 & 1 & 1 & 0 & 0 \\ \end{pmatrix} \begin{pmatrix} A\\ B\\ C\\ a\\ b\\ c\\ x\\ \end{pmatrix} = \begin{pmatrix} 90 \\ 80 \\ 70 \\ 100 \\ 10 \\ 20 \\ 30 \\ \end{pmatrix}\]

\[\begin{pmatrix} A\\ B\\ C\\ a\\ b\\ c\\ x\\ \end{pmatrix} = \begin{pmatrix} 15\\ 7\\ 3\\ 8\\ 0\\ 2\\ 65\\ \end{pmatrix}\]

\[Answer: \quad sum(a,b,c,x) = 75\]

Analysis of Problem C

Brute Force Determination of Rectangles

tally = Hash.new(0)
5.times do |startrow|
  6.times do |startcol|
    (startcol...6).each do |endcol|
      (startrow...5).each do |endrow|
        white = ((startcol <= 1) &&
           (endcol >= 1) && (startrow <= 1) &&
           (endrow >= 1)) ? "W" : "w"
      
        black = ((startcol <= 4) &&
           (endcol >= 4) && (startrow <= 3) &&
           (endrow >= 3)) ? "B" : "b"

        tally[black + white] += 1
      end
    end
  end
end
White Black Count
Yes Yes 16
Yes No 64
No Yes 64
No No 171

Analysis of Problem D

Analysis of Problem E

Triangulation

\[\begin{eqnarray} 2 &=& \frac{L_0 \times L_1}{2}\\ 3 &=& \frac{L_1 \times L_2}{2}\\ 5 &=& \frac{L_4 \times L_5}{2}\\ L_4 &=& \sqrt{L_0^2 + L_1^2}\\ L_5 &=& \sqrt{L_1^2+ L_2^2}\\ \sqrt{(L_0 +L_2)^2} &=& \sqrt{L_4^2 + L_5^2}\\ \frac{L_0}{L_1} &=& \frac{L_1}{L_2} = \frac{L_4}{L_5} = \frac{L_5}{L_7}\\ \end{eqnarray}\]

Analysis of Problem F

\[\begin{matrix} &&&&&&&\llap{1}&&&&&&&\\ &&&&&&\llap{1}&&\llap{1}&&&&&&\\ &&&&&\llap{1}&&\llap{2}&&\llap{1}&&&&&\\ &&&&\llap{1}&&\llap{3}&&\llap{3}&&\llap{1}&&&&\\ &&&\llap{1}&&\llap{4}&&\llap{6}&&\llap{4}&&\llap{1}&&&\\ &&\llap{1}&&\llap{5}&&\llap{10}&&\llap{10}&&\llap{5}&&\llap{1}&&\\ &\llap{1}&&\llap{6}&&\llap{15}&&\llap{20}&&\llap{15}&&\llap{6}&&\llap{1}&\\ \llap{1}&&\llap{7}&&\llap{23}&&\llap{35}&&\llap{35}&&\llap{23}&&\llap{7}&&\llap{1}\\ \end{matrix}\]

Brute Force

tally = Hash.new(0)
9.times do |i1|
  x1 = i1.eql?(7) ? 1 : 0
  9.times do |i2|          
    x2 = i2.eql?(7) ? 1 : 0
    9.times do |i3|         
      x3 = i3.eql?(7) ? 1 : 0
      9.times do |i4|      
        x4 = i4.eql?(7) ? 1 : 0
        9.times do |i5|
          x5 = i5.eql?(7) ? 1 : 0
          9.times do |i6|   
            x6 = i6.eql?(7) ? 1 : 0
            9.times do |i7| 
              x7 = i7.eql?(7) ? 1 : 0
              cnt7 = x1+x2+x3+x4+x5+x6+x7
              tally[cnt7] += 1
            end
          end
        end
      end
    end
  end
end
puts tally.inspect
Num of 7s Count Pattern
0 ******* \(1 \times 0\)
1 7****** \(7 \times 8^6\)
2 77***** \(23 \times 8^5\)
3 777**** \(35 \times 8^4\)
4 7777*** \(35 \times 8^3\)
5 77777** \(23 \times 8^2\)
6 777777* \(7 \times 8\)
7 7777777 \(1\)
1-7 Any pat with 7

A Better and Simpler Way

Combinations Formula Count
Find all without 0 \(A = 9^7\) 4782969
Find all without both 0 and 7 \(B = 8^7\) 2097152
Find differerence \(ans = A-B\) 2685817

Data Analytics

HOW?

WHY?

Framing an experimental question

\[\begin{matrix} \hbox{Cause} & \rightarrow & \hbox{Mediator} &\rightarrow & \hbox{Effect}\\ \hbox{(independant)} & &\hbox{(moderating)} & &\hbox{(dependant)}\\ \\ \hbox{Weather}\atop\hbox{conditions} &\rightarrow & \left\{\begin{matrix}\hbox{Holidays and weekends}\\\hbox{Political unrest}\\\hbox{Daylight savings time}\\\end{matrix}\right\} &\rightarrow & \hbox{Athletic event}\atop\hbox{participation}\\ \\ \hbox{Cost of}\atop\hbox{food delivery} &\rightarrow & \left\{\begin{matrix}\hbox{Ease of use}\\\hbox{Work from home order}\\ \hbox{Curfew and road blocks}\end{matrix}\right\} &\rightarrow &\hbox{Grab Revenue}\\ \end{matrix}\]

Experimentation

Control of factors that influence the result

Experiment designs

Common experimental issues