Saturday, December 10, 2016

Fixed Missing Soundcard

https://help.ubuntu.com/community/SoundTroubleshootingProcedure


If you are using Ubuntu 12.04 LTS, Ubuntu 14.04 LTS, Ubuntu 15.10, or Ubuntu 16.04 LTS, then please execute this command and reboot:

sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install pavucontrol linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; killall pulseaudio; rm -r ~/.pulse*; ubuntu-support-status; sudo usermod -aG `cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'` `whoami`


The same thing happened again... But only this cannot fix the whole thing.

I run the following commands in sequences and rebooted in between and solved the problem. I don't really know which is necessary and which don't...

killall pulseaudio; rm -r ~/.config/pulse/* ; rm -r ~/.pulse*
the reinstall alsa
sudo apt-get remove --purge alsa-base
sudo apt-get remove --purge pulseaudio
sudo apt-get install alsa-base
sudo apt-get install pulseaudio
sudo alsa force-reload

then download kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.8/ and 
sudo dpkg  -i linux-headers-4.8.0-040800_4.8.0-040800.201610022031_all.deb
then reinstall by aptitude
sudo aptitude --purge reinstall linux-sound-base alsa-base alsa-utils linux-image-$(uname -r) linux-image-extra-$(uname -r) libasound2

then follow the troubleshooting procedure
sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install pavucontrol linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; killall pulseaudio; rm -r ~/.pulse*; ubuntu-support-status; sudo usermod -aG `cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'` `whoami`
and 
sudo reboot

After the first time, follow the procedure again
sudo apt-get update;sudo apt-get dist-upgrade; sudo apt-get install pavucontrol linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; sudo apt-get -y --reinstall install linux-sound-base alsa-base alsa-utils lightdm ubuntu-desktop  linux-image-`uname -r` libasound2; killall pulseaudio; rm -r ~/.pulse*; ubuntu-support-status; sudo usermod -aG `cat /etc/group | grep -e '^pulse:' -e '^audio:' -e '^pulse-access:' -e '^pulse-rt:' -e '^video:' | awk -F: '{print $1}' | tr '\n' ',' | sed 's:,$::g'` `whoami`
and shut down the computer then turn it back on. Do not reboot it, this is important and I don't know why.

Then the sound card is back.






Tuesday, December 2, 2014

Extra problem solving

What is the sum of all natural numbers?
S = 1 + 2 + 3 + 4 + ... = ?


Pick S1 = 1 - 1 + 1 - 1 + ...
Then S1 + S1 = (1 - 1 + 1 - 1 + 1 ...)
                  +(1 - 1 + 1 - 1 + ...) # shift one spot
Then 2S1 = 1 + 0 + 0 + 0 + ...
         = 1
Then S1  = 1/2
Pick S2  = 1 - 2 + 3 - 4 + 5 ...
Then 2S2 = 1 - 2 + 3 - 4 + 5 ...
             + 1 - 2 + 3 - 4 ...    # shift one spot
         = 1 - 1 + 1 - 1 + 1 ...
         = S1 = 1/2
Then S2  = 1/4
Then S - S2 = 1 + 2 + 3 + 4 + 5 + 6 + ...
            -(1 - 2 + 3 - 4 + 5 - 6 + ...)
            = 0 + 4 + 0 + 8 + 0 + 12 + ...
            = 4(1 + 2 + 3 + 4 + ...)
            = 4S
Then 3S = -S2
Then S = -1/4 / 3 = -1/12
Conclude S = -1/12

This is an astonishing result. As common sense, the value of S should go to infinity. However it give us -1/12. I suggest this -1/12 should replace 42 to be the meaning of life. And this proof is actually used in modern physics for example in string theory and calculating Casimir effect.

resource:
https://www.youtube.com/watch?v=w-I6XTVZXww&feature=youtu.be
http://en.wikipedia.org/wiki/1_%2B_2_%2B_3_%2B_4_%2B_%E2%8B%AF

Week #12

Thoughts:

This week we continue the topic and mainly talked about countable.
We say a set is countable if its size smaller or equal to the size of N. And it is pretty astonishing to hear that set of odd and set of even
have the same size of natural number. Because in common sense they suppose to be smaller. And even more mind-blowingly, R is countable. And much more mind-blowingly, (0, 1) is uncountable. Which means it is actually have larger size than R! And in topology its called dense set. And I found that there is a course MAT327 talking about this. WOW. I'm going to take that course in the future.

Problem Solving:




Before actually working on this problem, our group tried to break the problem into smaller pieces like 2 * 1 or 3 * 2. And then find that the formula should be something like m + n - 1. However, this won't work in the situation 4 * 2 which have 4 squares but the formula give us 7. So I think we should change the "1" part. After checking more special cases like 3 * 3, 4 * 4, I notice that it was related to gcd(m, n), and the formula should change into m + n - gcd(m, n).
After we got the formula, I think that gcd(m, n) exists because the line cross the vertex of the squares. If it cross the vertex of the square, the line will cross one less square. So the formula should be m + n - gcd(m, n).

Week #11

Thoughts:

This week we talked about probably the coolest but most confusing topic in the whole class, halting program and computability.

- Halting Program.
A halting program (e.g. halt(f, i)) is a program that predict that the input f(i) will halt or not. And we proved it is impossible to implement this program. An imprecise way of explaining this is if there is a function that is running, we can't tell if it fall into an infinite loop or it's just on it's way producing an out put. For example a program has ran for 5 hours, we cannot say it won't halt since it ran for a long time. Maybe it will halt at 7 hours, maybe it will halt at 20 hours, maybe it will take a year, a century to halt. And then professor talked about Collatz conjecture as an example.

-Collatz Conjecture
Here are the explanation on wikipedia:
"Take any natural number n. If n is even, divide it by 2 to get n / 2. If n is odd, multiply it by 3 and add 1 to obtain 3n + 1. Repeat the process (which has been called "Half Or Triple Plus One", or HOTPO) indefinitely. The conjecture is that no matter what number you start with, you will always eventually reach 1. The property has also been called oneness."

It was Collatz, a student in University of Hamburg first came up in 1930, and then it became a open question since then. many mathematicians such as Shizuo Kakutani had working on it. But as  Hungarian mathematician Paul ErdÅ‘s says "Mathematics may not be ready for such problems.", no one were able to prove or disprove it. The lecture slice has a small mistake, modern day mathematicians have checked that the code will halt for every integer up to 2^60 in 2009, four times more than 2^58. And I tried to be a genius solving this historically hard question and gave up in 5 minutes. However, visualized graphs of that program are pretty cool.

Back to halt(h, i), during the lecture prof used navel_gaze(f) to prove that it is impossible to implement halt(h, i).
If we defined a function navel_gaze this way:

def navel_gaze(f):
    while H(f, f):
        pass
    return 42    # meaning of life

consider navel_gaze(navel_gaze), if the it halts, then H(navel_gaze, navel_gaze) is false, which means navel_gaze(navel_gaze) won't halt.
But if it doesn't halt, then H(navel_gaze, navel_gaze) is true, then it will halt. Since both possible cases leads to contradictions, We cannot implement the function halt(). And we say that H(f, i) is computable.

- 42
In The Hitchhiker's Guide to the Galaxy by Douglas Adams, 42 is "The Answer to the Ultimate Question of Life, the Universe, and Everything". And the movie is pretty interesting.

Week #10


Thoughts:

Big-Oh, Big-Omega, Big-Theta...


This week we talked about concepts of Big-Oh, Big-Omega and Big-Theta and introduced some proofs of them. And here I summarized the strategy of writing a proof.

1.How to write a proof:

Step 1:
Write down the proof structure, leave the value of c and B blank.

Pick c = ______ , then c \in R+
Pick B = ______ , then B \in N
Assume n >= B



Conclude n >= B => f(n) <= cg(n)   # this is big-Oh, if it's big-Omega then flip the inequality
Conclude exists c ...


Step 2
Make every element in the polynomial to the same with the largest power in the polynomial. Find the value of B.

Then f(n)  = 5n3 + 4n2 + 2n  + 1
          <= 5n3 + 4n3 + 2n3 + n3    # B >= 1


Step 3
Merge all the terms, find the value of c

... = 12n3
    = cn3    # c = 12
    = cg(n)

Step 4
Complete the proof

2. Meaning of Big-Oh, Big-Omega and Big-Theta.

There do not exists a method to precisely predict the time an algorithm will take. It heavily depends on the hardware and input. The only way to know the time of the algorithm takes is to actually run the program on the machine and measure the time. But in some cases for example the programis extremely complicated, or for example in the scenario that a programmer is trying to determine between two algorithms. However, time complexity provide us a method to compare two different algorithms. So we can know directly what kind of sorting algorithm we should use for this intput, what kind of algorithm of data processing for that input. Time complexity is a powerful tool for computer scientist to maximum their efficiency.

Week #9

Thoughts

1. Assignment #2
Unlike the failure of assignment 1, our group got full mark in assignment 2.

- material
Claim 1.2 ~ Claim 1.3 are very challenging. Claim 1.2 and 1.3 seemed to be limit questions but actually they are more related to definition of absolute value.

- something about LaTeX
This time I format everything using LaTeX. Although I spent more time typing and searching for commands, it is worthy because it provide me a nice looking assignment and it's also a nice practice for LaTeX. And here are some tips I discovered and want to share to every body.

* I used \begin(equation*) with \begin(split) to format all my proof. And using & to align comments.


\begin(equation*)
\begin(split)
& \text{Assume} x \in\mathbb{N}... &
& \# \ \text{generic} & \\
& \indent \text{Then} ... &
& \# \ \text{comment here!} & \\
...
\end(split)
\end(equation*)


* And also & is very useful in multiply-line equations.


& f(x) & & = & & (line 1) &
& \# \ \text{comment} &\\
&&  & = & & (line 2) &
& \# \ \text{comment} &\\
...

Week #8

Thoughts

This week we mainly talked about some more big-Oh.
Big-Oh is one of the most important concept in computer science. And it is very important in computer science.

Despite all that, this week I'm going to talk about sorting algorithms. And here are the algorithms on Wikipedia:
Quick sort
Heap sort
Merge sort
Intro sort
Insertion sort
Selection sort
Bubble sort
Odd-even sort
Cocktail sort
Cycle sort
Merge insertion (Ford-Johnson) sort
Smoothsort
Timsort
...

But I found one sort Spaghetti sort is very special because it uses linear time O(n). In short, the algorithm is if you have a set of natural numbers, then for each number x in the list, obtain a rod of length. Once you have all the spaghetti rods, take them loosely in your hand and lower them to the table to make them stand upright. Then for each rod, lower your other hand from above until it meet with a rod, and that rod is clearly the longest. Remove this rod and move it into the the front of the output list. Repeat until all rods have been removed. Since the time of preparing the n rods of spaghetti takes linear time, and lowering the rods on the table takes constant time, the whole process takes linear times, O(n).
However, this algorithm is impossible in actual programming. It requires n processor to process the lowering action. But this method is useful in our daily life, for example sorting the length of pencils.