22 February 2013

Sound Blaster Play on Ubuntu

Haven't been able to listen to audio for quite awhile on my Ubuntu.
I finally got myself a Sound Blaster Play.
It didn't worked by just simply plugged.
Calling alsamixer, the sound card used by the system is the default Intel one, not recognizing the Sound Blaster.

So, I tried changing the default sound card, by what's instructed in this post
1. cat /proc/asound/modules
see your default sound card name
2. sudo gedit /etc/modprobe.d/alsa-base.conf
# Prevent abnormal drivers from grabbing index 0
options snd_hda_intel index=1 #change default sound card index to 1

3. reboot

After rebooting, I still couldn't here any sounds.
I couldn't even open alsamixer anymore... =____=;;;
And finally it was solved by opening gnome-volume-control and unmute the sound
I'm using wmii, so I don't have any sound bar, I wonder if the problem was just because it was muted...
But oh well, now I can listen to audio, nevermind what was it...

18 February 2013

Lapack in Mac OS X

I previously used this when compiling:
gcc ... -llapack
It worked, but I came into error for these two:
 dgetrf_
 dgetrf_
It was solved by using
gcc ... -framework Accelerate

Using Posix Threads in Mac OS X

Got into an EMFILE error
Too many semaphore descriptors or file descriptors are currently in use by this process.
when trying to run a program which runs on Ubuntu well.
The problem is that apparently Mac creates a file for every semaphore, and there's a limit for the number of opened files at one time, and it's set very low for Mac...
This can be fixed by
ulimit -n 10000
do not use sudo.

06 February 2013

Put picture in absolute position in Latex (x,y)


\usepackage[dvipdfm]{graphicx}
\usepackage{mediabb} %for putting in jpg images
\def\Put(#1,#2)#3{\leavevmode\makebox(0,0){\put(#1,#2){#3}}}
...

\begin{document}
\Put(320,-254){\includegraphics[height=3.5cm]{p.jpg}}
% 320 is x to the right at increasing value
% -254 is y to bottom at decreasing value

31 January 2013

r plot


Saving the plot beforehand
jpeg('rplot.jpg')
plot(x,y)
dev.off()

If error for above, save current active plot
dev.copy(png,'myplot.png')
dev.off()

26 January 2013

2D PCA with SVD in R

res.svd <- svd(x)
t <- res.svd$u %*% diag(res.svd$d)
t1 <- t[,1]
p1 <- res.svd$v[,1]
gues <- t1 %*% t(p1)
plot(x)
points(gues[,1],gues[,2],col='red')

25 January 2013

Factor Analysis in R


fa.alldat <- factanal(alldat[c(1,2,3)],1,scores="regression");
biplot(fa.alldat$scores,fa.alldat$loadings,cex=0.5)


factanal
using maximum likelihood factor analysis

fa
is basically using Principal Axes