Predicting Emotions Perceived from Sounds

Abstract: Sonification is the science of communication of data and events to users through sounds. Auditory icons, earcons, and speech are the common auditory display schemes utilized in sonification, or more specifically in the use of audio to convey information. Once the captured data are perceived, their meanings, and more importantly, intentions can be interpreted more easily and thus can be employed as a complement to visualization techniques. Through auditory perception it is possible to convey information related to temporal, spatial, or some other context-oriented information. An important research question is whether the emotions perceived from these auditory icons or earcons are predictable in order to build an automated sonification platform. This paper conducts an experiment through which several mainstream and conventional machine learning algorithms are developed to study the prediction of emotions perceived from sounds. To do so, the key features of sounds are captured and then are modeled using machine learning algorithms using feature reduction techniques. We observe that it is possible to predict perceived emotions with high accuracy. In particular, the regression based on Random Forest demonstrated its superiority compared to other machine learning algorithms.

\section{Introduction}
\label{sec:intro}
{\it Affective Computing} is a multidisciplinary field including computer science, cognitive science, and psychology~\cite{Tao2005}. From the computer science perspective, it can be considered as a subfield of artificial intelligence also called ``{\it artificial emotional intelligence}'' that focuses on natural interactions between humans and machines. It aids development of tools to recognize affective states and express emotions~\cite{Picard1997}.

Affect representation can be modeled in a 2D space of 1) {\it arousal} (A), which is the level of eventfulness from bored to excited, and 2) {\it valence} (V), which is the level of pleasantness from sad to happy representing the AV space as proposed by Russell~\cite{Russell1980}. There is also a third dimension called ``dominance'' which is the level of control from weak to empowered~\cite{Russell1980}. The dominance dimension in excluded from this work.
The emotions can be acquired by self-assessment questionnaires using Self-Assessment Manikins (SAM)~\cite{Bradley1994} or physiological signals such as heart rate, skin temperature (SKT) or brain signals using Brain Computer Interfaces (BCIs) such as  Electroencephalogram (EEG).

{\it Emotion recognition} is a task in affective computing, which studies the techniques for identifying emotions from stimuli such as text, picture, audio and video. These artifacts along with their annotations such as emotion and semantics are usually stored in affective datasets. {\it Audio Emotion Recognition} (AER) is a subfield of emotion recognition and includes emotion recognition from music, speech/voice and sample sound/sound event. {\it Sound emotion recognition} is a relatively new field of research and has broad applications from automatic sound design systems to designing robots, as affective companions. Two types of emotions can be considered when someone is listening to a soundscape: ``{\it Perceived Emotion},'' the emotion expressed by the sound source, and ``{\it Induced Emotion},'' the emotion invoked in the listener.

Audio emotion recognition helps to understand the characteristics of audio samples (e.g. music and soundscapes) regarding the emotions which are induced or perceived and therefore, is useful for designing automated sonification frameworks. Sonification is a field of research that aims to convey information using sound which has been applied in Cyber Physical Systems (CPS) ~\cite{2020Iber, 2019Lenzi} or it can be applied in disaster management~\cite{Nguyen2019}. Auditory representation of emotion, which is also called ``sonification of emotion", is  done by two methods of mapping sounds to an emotion space (e.g. AV space)~\cite{2014winters}: Ecological design, which uses acoustic features suggested by the psychological study of musical emotion such as~\cite{Weninger2014}; and computational design, which utilizes automatic feature extraction methods, such as the MIRToolbox~\cite{MIRToolbox}.
Considering emotion recognition, sonification and Cyber Physical Systems, a novel area of research called ``{\it sonification of emotion in CPSs and IoTs}'' can be explored.

In designing such sonification-based systems for emotion recognition in CPS and IoT platforms, it is important to represent operational events through meaningful sounds that reflect the emotions perceived or induced by the events. The automatic and effective selection of proper sounds in order to represents events in CPSs depends on whether there are {\it common psychoacoustic features} of sounds that could reliably express emotions represented in a dimensional model of affect.
More specifically, the objective is to explore the possibility of utilizing sound features in predicting induced or perceived emotions.

This paper intends to investigate the prediction of emotions in AV space perceived from soundscapes with machine learning techniques and reports the best features that can be used in sonification of emotion with application in computer science and more importantly CPSs. The key contributions of this paper are as follows:

\begin{itemize}
    \item[--] Compare the performance of several machine learning algorithms to the emotion recognition problem,
    \item[--] Perform feature reductions and capture the accuracy of the models based on the selected features, and
    \item[--] Identify common features deemed to be important for modeling both arousal and valence (AV space).
\end{itemize}

The remainder of this paper is organized as follows: the related work is reviewed in Section  \ref{sec:related}. Section \ref{sec:dataset} briefly represents the dataset used for this experiment. In Section \ref{sec:models}, machine learning techniques studied in this work are briefly explained. In Section \ref{sec:results}, results obtained by models with and without feature reduction/selection are presented. Section \ref{sec:conclusion} concludes the paper and highlights the future  directions.

\vspace{-0.05in}
\section{Related Work}
\label{sec:related}

Fan et al.~\cite{EmoSoundscape} created the Emo-soundscape dataset of audio samples and their perceived emotion to provide a benchmark for Soundscape Emotion Recognition (SER). They evaluated the dataset using Support Vector Regression (SVR) models. For the feature extraction phase, both YAAFE~\cite{Mathieu2010} and MIRToolbox~\cite{MIRToolbox} tools were utilized. Using the mean and standard deviation of the features, they extracted 122 audio features. Finally, they removed the features whose variances were lower than $0.02$ and thus obtained 39 features. They used this 39-D vector of features to train the SVR models to predict arousal and valence and assess them through $MSE$ and $R^2$ as performance metrics.
They reported $MSE = 0.048$ and $R^2 = 0.855$ for arousal and $MSE = 0.124$ and $R^2 = 0.629$ for valence, respectively.

Improving their work, Fan et al.~\cite{Fan2018} used deep learning techniques to predict arousal and valence independently. They used the Emo-Soundscapes dataset for their framework. Given that deep learning methods need great amounts of data, they augmented the dataset using a windowing method to increase the number of samples. By using 30 consecutive windows for each augmented sound sample, they ended up with $8,491$ samples, each being $1.393$ seconds long. They used two different techniques for feature extraction. The the first set of features obtained from a deep CNN model applied in audio classification~\cite{Hershey2017}. For generating the second set of features, they utilized YAAFE~\cite{Mathieu2010} and MIRToolbox~\cite{MIRToolbox} and extracted 54 features including: loudness, energy, perceptual spread, perceptual sharpness, spectral flatness, spectral rolloff, spectral flux, spectral slop, spectral variation, spectral shape, temporal shape, zero cross rate, and 13 MFCCs. They extracted features for each window and because there were 30 windows for each augmented sound sample, they had 54x30 features for each augmented sample.
Furthermore, they used five different models including: 1) CNN trained through supervised fine-tuning,
2) CNN trained from scratch that included two convolutional layers followed by one dense layer and 54x30 input features, 3) LSTM-RNN trained from scratch with two stacked LSTM units and 54x30 input features, 4) standard SVR, which uses the first set of features as the input, and 5) Radial Basis Function (RBF) kernel and a combination of CNN and SVR, where VGG-like CNN is used as the feature extractor, and its output was fed into the SVR with RBF kernel.
They achieved the best arousal prediction with $MSE = 0.035$ and  $R^2 = 0.892$ using the CNN trained from scratch and the best valence prediction with  $MSE = 0.078$ and  $R^2 = 0.759$ using fined-tuned CNN.

Ntalampiras~\cite{Ntalampiras2020} provided a comparison between emotion prediction from singleton soundscapes and mixed soundscapes using a CNN model. The author used Emo-Soundscape dataset and extracted the features from sound samples using log-Mel spectrum~\cite{Kinnunen2004} which is a spectrogram that the frequencies are converted to the Mel scale. He showed that if the feature vectors of mixed soundscapes and its components (singleton soundscapes) are reduced to their three principal components, most mixed soundscapes are located between its original soundscapes. Ntalampiras conducted the experiment using 2D-CNN models first on a subset of the dataset only containing singleton soundscapes, and then on the whole dataset with mixed soundscapes. Ntalampiras reported the best prediction on the dataset containing both original and mixed samples with $MSE$ scores of $0.010$ and $0.016$ for arousal and valence
\vspace{-0.1in}
\section{Dataset Description and Analysis}
\label{sec:dataset}
In order to conduct our experiment, we used the Emo-Soundscape dataset~\cite{EmoSoundscape}, which consists of two subsets. The first subset contains 600 audio samples categorized into 6 families, 100 samples each based on Schafer's soundscape taxonomy~\cite{Schafer1977} including: natural sounds, human sounds, sounds and society, mechanical sounds, quiet and silence, and sounds as indicators. The second subset contains 613 samples, each being a combination of soundscapes from two or three classes out of the first subset. All these soundscapes are annotated with their perceived emotion. We used the first subset of this dataset for our experiment. As to the features, we extracted 68 features using MATLAB MIRToolbox~\cite{MIRToolbox}.

The MIRToolbox extracts the (psycho)acoustic and musically related features from databases of audio files for statistical analysis~\cite{MIRToolbox2007}. Following Lange and Frieler~\cite{Lange2018}, a total of 68 features were extracted from each sound sample that represent either the arithmetic mean or the sample standard deviation of the frame-based features computed over default window sizes (typically 50 ms for low-level, and 2-3 seconds for medium level features) and a 50\% overlap. These features can be classified according to their (psycho)acoustic family ({\it dynamics}, {\it rhythm}, {\it timbre/spectrum}, {\it pitch}, and {\it tonality}).

Figure \ref{fig:valence-vs-arousal} shows the scatter plot of normalized values of arousal versus valence for the Emo-Soundscape dataset. There exists a visible trend that suggests a negative correlation between values for arousal and valence. This trend is confirmed after calculating the Pearson correlation $r$ between the two series of values, resulting $r=-0.711$ (p-value $< 0.01$). This correlation suggests that in this dataset, sound stimuli that express excitement are likely to be perceived as unpleasant.

\begin{figure}[h]
  \centering
  \includegraphics[width=\linewidth]{Figures/emo-AV-scatter.png}
  \caption{Scatter plot of Emo-Soundscape normalized data points on AV space. The circumplex model is adapted from~\cite{Valenza2012}.}
  \label{fig:valence-vs-arousal}
  \vspace{-0.2in}
\end{figure}

Figure \ref{fig:corr-heatmap} shows the heatmap of all pairwise correlations for the 68 features. The heatmap shows that there are more features with positive correlations than negative ones. Also, there exists a very high positive correlation between features dealing with MFCC spectral measures.

\begin{figure*}[!h]
  \centering
  \includegraphics[width=0.80\linewidth]{Figures/correlation-heatmap.png}
  \caption{Correlation heatmap between features.}
  \label{fig:corr-heatmap}
  \vspace{-0.2in}
\end{figure*}

\vspace{-0.05in}
\section{Prediction Models}
\label{sec:models}
We used different regression models to predict arousal and valence separately, including four linear models:
\begin{itemize}
    \item[--] $LinearRegression()$, an ordinary least squares linear regression model,
    \item[--] $Lasso()$, a linear model with L1 regularization,
    \item[--] $ElasticNet()$, a linear model with L1 and L2 regularization, and
   \item[--] $SVR(kernel='linear')$, an Epsilon-Support Vector regression model with linear kernel.
\end{itemize}
In addition to these linear models, we explored four non-linear regression models, bringing the total number of prediction models to eight:
\begin{itemize}
    \item[--] $2-layer\ MLP$, a shallow Neural Network model,
    \item[--] $SVR(kernel='rbf')$, an Epsilon-Support Vector regression model with RBF kernel,
    \item[--] $SVR(kernel='poly')$, an Epsilon-Support Vector regression model with polynomial kernel, and
    \item[--] $RandomForestRegressor()$, an ensemble estimator that fits a number of decision trees on different subsets of samples.
\end{itemize}

It should be noted that although deep models such as CNN succeed in achieving remarkable outcomes in the literature (e.g., sequence modeling \cite{DBLP:conf/compsac/Tavakoli20}), we did not examine deep models in our experiment for two reasons. Firstly, the size of the Emo-Soundscape dataset is not large enough (i.e., only 600 samples) for such models and deep models need a fairly large amount of data to perform well. Secondly our feature vector is a 1D vector containing 68 features, which is not suitable to feed into a 2D CNN model. In addition, augmenting data using windowing technique violates the assumption of independence between samples since each of the component sounds from a given sound sample will receive the same rating. Therefore, we decided to examine the dataset without any data augmentation and without any changes in the feature vector using the models explained above.

\subsection{Feature Reduction/Selection}
Feature reduction and feature selection help to reduce the number of features and thus the dimensionality of data. Feature selection aims to select a subset of features that represents the entire set of features and helps us to interpret the model. However, feature reduction converts features to a lower dimension. After examining the models using all 68 features, we applied ``Principal component analysis'' (PCA) and ``Univariate linear regression test'' (KBest) for feature reduction and feature selection, respectively.
PCA  is  a  linear  dimensionality  reduction  technique  that uses  Singular  Value  Decomposition  (SVD)  to  project  the given  data  to  a  lower  dimensional  space. Given  that  we  did  not have  any  estimation  for  the  amount  of  feature  reduction,  we decided  to  consider  the  90\%  of  explained  variance  of  the dataset  as  the  dimension  of  PCA.
KBest is a  univariate linear   regression   tests for   selecting $k$ best  features using a scoring function. We considerd 25Best features using F statistic as the statistical test between outputs and features for regression.

\subsection{Hyperparameter Tuning}
Hyperparameter tuning is the process of selecting the best parameters for a model to obtain the optimal results. Grid search is a technique that can be employed to find the optimal parameters of the model through which all combinations of the determined values for parameters are examined. We performed a grid search for hyperparameter tuning on the Random Forest model to find the optimal values. Here is the list of parameters that were tuned for the Random Forest model:
\begin{itemize}
    \item[--] $n\_estimators: [50, 100, 150, 200, 250, 300]$, number of trees in the forests,
    \item[--] $max\_depth:[5, 10, 20, 30, 50]$, maximum number of levels in each decision tree,
    \item[--] $min\_samples\_split:[2,3,4,5,6,7]$, minimum number of data points placed in a node before the node is split,
    \item[--] $min\_samples\_leaf:[1,2,3,5]$, minimum number of data points allowed in a leaf node,
    \item[--] $k:range(10,30)$, number of features selected using KBest.
\end{itemize}

\subsection{Evaluation Metrics}
In order to measure the performance of the regression models,
$RMSE$ and $R^2$ were chosen to evaluate the performance of each regression model.

$R^2$  provides a comparison of total sum of squares of prediction error with total sum of squares of error with mean. The closer the value of $R^2$ to 1 is, the better the regression model will be.
\iffalse
\vspace{-0.2in}
\[
R^2=1-\frac{\Sigma(y_i-\hat{y_i})^2}{\Sigma(y_i-\Bar{y_i})^2}
\]
\fi
It should be mentioned that $R^2$ is less common used metric for assessing non-linear models~\cite{Spiess2010}.

$RMSE$ can be considered as the standard deviation of the prediction errors. Because it applies a high penalty on large errors, it is beneficial when large errors are unwanted.
\iffalse
\[
    RMSE=\sqrt{\frac{\Sigma(y_i-\hat{y_i})^2}{n}}
\]
\fi

\begin{figure*}[htpb!]
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-all.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-all}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-all.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-all}
    \end{subfigure}%

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-pca90.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-pca90}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-pca90.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-pca90}
    \end{subfigure}

\iffalse
        \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-pca80.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-pca80}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-pca80.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-pca80}
    \end{subfigure}

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-pca70.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-pca70}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-pca70.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-pca70}
    \end{subfigure}
\fi

        \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-25best.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-25best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-25best.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-25best}
    \end{subfigure}

\iffalse

            \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-15best.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-15best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-15best.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-15best}
    \end{subfigure}

            \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-5best.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-5best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-5best.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-5best}
    \end{subfigure}

            \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-rmse-2best.png}
      \caption{$RMSE$}
      \label{fig:aro:emo-rmse-2best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/aro/emo-r2-2best.png}
      \caption{$R^2$}
      \label{fig:aro:emo-r2-2best}
    \end{subfigure}
\fi

    \caption{Arousal prediction.}
    \label{fig:aro_allfeatures}
    \vspace{-0.2in}
\end{figure*}

\section{Prediction Results}
\label{sec:results}
This section reports the results of our analysis on building models for predicting perceived emotions. As discussed earlier, emotions perceived or induced from sounds are quantified in terms of two factors: 1) arousal, and 2) valence. We first present the performance of predicting models for arousal, and then discuss our results for predicting valence.

\begin{figure*}[htpb!]

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-all.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-all}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-all.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-all}
    \end{subfigure}%

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-pca90.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-pca90}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-pca90.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-pca90}
    \end{subfigure}

\iffalse

        \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-pca80.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-pca80}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-pca80.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-pca80}
    \end{subfigure}

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-pca70.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-pca70}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-pca70.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-pca70}
    \end{subfigure}
\fi

        \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-25best.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-25best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-25best.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-25best}
    \end{subfigure}

\iffalse

            \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-15best.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-15best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-15best.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-15best}
    \end{subfigure}

    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-5best.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-5best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-5best.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-5best}
    \end{subfigure}

            \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-rmse-2best.png}
      \caption{$RMSE$}
      \label{fig:val:emo-rmse-2best}
    \end{subfigure}%
    \begin{subfigure}{0.50\textwidth}
      \includegraphics[width=\textwidth]{Figures/val/emo-r2-2best.png}
      \caption{$R^2$}
      \label{fig:val:emo-r2-2best}
    \end{subfigure}
\fi

    \caption{Valence prediction.}
    \label{fig:val_allfeatures}
    \vspace{-0.12in}
\end{figure*}

\subsection{Predicting Perceived Arousal of Sounds}

The barplots shown in Figure \ref{fig:aro_allfeatures} summarize the results for predicting arousal. We report the results for all features, PCA 90, and 25 Best.

\subsubsection{All Features}

Using the MIR toolbox in Matlab, we extracted 68 acoustic features from the Emo-Soundscape dataset. As illustrated in Figure \ref{fig:aro:emo-rmse-all}, the $RMSE$ values for the train dataset (i.e., the blue bars) are around $0.09$ and $0.39$ obtained by Random Forest and Linear-Lasso, respectively. Likewise, the $RMSE$ values for test dataset (i.e., the red bars) are around $0.24$ for Random Forest and $0.56$ for Support Vector Regression (Polynomial) (SVR-Poly), respectively.

Similarly for $R^2$ values and according to Figure \ref{fig:aro:emo-r2-all}, for the training datasets the highest value is obtained by Random Forest ($0.98$), and the lowest value is offered by Linear-Lasso ($0.61$). For the test datasets, the highest $R^2$ value was achieved by Random Forest ($0.85$), and the lowest is achieved by Support Vector Regression (Polynomial) (SVR-Poly) ($0.1$).

According to our results, the Random Forest-based models outperformed other models with respect to $RMSE$ and $R^{2}$. The Support Vector Regression (Polynomial) (SVR-Poly) clearly suffered from an overfitting problem because the metrics calculated for the test datasets are very poor.

\subsubsection{PCA 90}

The application of PCA with 90\% variations of the dataset yielded 28 features. Figures \ref{fig:aro:emo-rmse-pca90} and \ref{fig:aro:emo-r2-pca90} illustrate the $RMSE$ and $R^2$ values when PCA with 90\% variation is utilized for prediction of arousal.

According to Figure \ref{fig:aro:emo-rmse-pca90}, the minimum and maximum $RMSE$ values were obtained for the training dataset by Random Forest ($0.12$) and Linear-Lasso ($0.42$), respectively. Furthermore, for the test dataset, the minimum and maximum $RMSE$ values were obtained by Random Forest ($0.34$) and Linear-Lasso ($0.42$). The results indicate that, even with the reduced number of features using PCA 90\%, the ensemble-based Random Forest models outperformed the other machine learning estimators.

In terms of $R^2$, we obtained similar results for both training and testing datasets when the features extracted by PCA 90\% are utilized for prediction of arousal. For the training dataset, the Random Forest offered $0.97$ (the highest of all $R^2$ calculated); whereas, Linear-Lasso exhibited a very poor result, $R^2 = 0.54$. On the other hand, the maximum $R^2$ for the test dataset is achieved by MLP 2-layer with $0.8$ and the poorest result is obtained by SVR-Poly ($R^2 = 0.27$).
The Random Forest exhibits a competitive estimate of $R^2 = 0.7$ for the test dataset.

Overall, the results indicate that reducing the number of features to 28 by PCA 90\%, the Random Forest model still offers the best results in predicting arousal; whereas, other models such as Linear-Lasso and SVR-Poly produce poor estimates of model fit.

\subsubsection{25 Best}

Furthermore, we studied the performance of the prediction models when the 25 best features were utilized for building the models. Figures \ref{fig:aro:emo-rmse-25best} and \ref{fig:aro:emo-r2-25best} depict the prediction results through $RMSE$ and $R^2$ values.

For the training, the best $RMSE$ value is offered by Random Forest ($0.09$); whereas, the worst performance is exhibited by Linear-Lasso ($0.41$). For the test dataset, the best $RMSE$ value is again provided by Random Forest ($0.24$); whereas, the worst $RMSE$ value is calculated by SVR-Poly ($0.63$).

In terms of the $R^2$ values and for the training dataset, the best performer is again Random Forest with $R^2 = 0.98$ and the worse model is Linear-Lasso with $R^2 = 0.57$. Similarly, for the test dataset, the best performing model is Random Forest with $R^2 = 0.84$ and the worst performing model is again SVR-Poly with $R^2 = 0.06$.

In compliance with all features and PCA 90\%, the results obtained by the 25 best features indicate that Random Forest is able to build a better prediction model for predicting arousal.

\subsubsection{All-Features vs. PCA 90\% vs. 25 Best}

Taking the best evaluation values for $RMSE$ and $R^2$ into consideration when applying all features, PCA 90\%, and 25 Best, we observe that 1) Random Forest is the dominant model among all the regressors studied, and 2) all features and 25 best features exhibit similar results in predicting arousal, followed by PCA 90\%, which provided slightly weaker estimates when predicting accuracy in comparison to all features and 25 best features. Given the cost of extracting features, the results indicate that building a prediction model based on 25 best features is a better choice, yielding more accurate prediction models.

\subsection{Predicting Valence Perceived from Sounds}

As the second dimension of predicting perceived emotions, we built similar models for prediction of valence. Similar to the study we performed in the previous section, we built predictive models based on all features, PCA 90\%, and 25 Best features. The barplots shown in Figures \ref{fig:val_allfeatures} present the estimates of $RMSE$ and $R^2$ for the valence predictions.

\begin{table*}[!ht]
\caption{Exhaustive search results for the best A/V prediction.}
\centering
\begin{tabular}{|l|l|l|l|l|l|l|l|l|}
\hline
\multicolumn{1}{|c|}{\bf output} &
\multicolumn{1}{|c|}{\bf KBest} &
\multicolumn{1}{|c|}{\bf n\_estimators} &
\multicolumn{1}{|c|}{\bf max\_depth} &
\multicolumn{1}{|c|}{\bf min\_samples\_split} &
\multicolumn{1}{|c|}{\bf min\_samples\_leaf} &
  \begin{tabular}[c]{@{}l@{}}{\bf Train}\\ $RMSE$\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}{\bf Test} \\ $RMSE$\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}{\bf Search} \\ {\bf Time}\end{tabular} \\ \hline
Arousal    & 26    & 200   & 20   & 3   & 1   & 0.09   & 0.25   & 5:13:37   \\ \hline
Valence    & 29    & 100   & 30   & 2   & 1   & 0.13   & 0.37   & 5:17:51   \\ \hline
\end{tabular}
\label{tab:Exhaustive Search Results for the Best A/V Prediction}
\vspace{-0.1in}
\end{table*}

\subsubsection{All Features}

Similar to the process employed in building models for predicting arousal, we first focused on all 68 features for predicting valence. Figures \ref{fig:val:emo-rmse-all} and \ref{fig:val:emo-r2-all} illustrate the barplots for $RMSE$ and $R^2$ values yielded by machine learning models. For the test data, the best $RMSE$ value was obtained by Random Forest ($0.14$) and the worst $RMSE$ value was offered by Linear-Lasso ($0.46$). Similarly, for the test data, the best performing model was Random Forest ($0.37$), whereas the worst prediction model was once again Linear-Lasso ($0.47$).

In terms of utilizing $R^2$ for model assessment, for the train dataset, the best performing model was Random Forest, offering a high value of $R^2 = 0.94$; The worst prediction model was again Linear-Lasso. Similarly, for the test dataset, the best performing  prediction model was Random Forest with $R^2 = 0.59$, whereas, the worst model was captured by Linear-Lasso ($R^2 = 0.35$).

\subsubsection{PCA 90}

Taking into account the 28 acoustic features of sounds for the purpose of predicting valence, we built similar prediction models whose performance are visualized through Figures \ref{fig:val:emo-rmse-pca90} and  \ref{fig:val:emo-r2-pca90}.

According to Figure \ref{fig:val:emo-rmse-pca90}, Random Forest with $0.15$ and $0.4$ $RMSE$ values outperformed other regression models for both training and testing datasets, respectively. The worst model fitting and predictions were produced once again by Linear-Lasso, with $0.48$ and $0.49$ for $RMSE$ of training and testing datasets, respectively.

Similarly, we observe better performance pronounced in terms of $R^2$ by Random Forest. The $R^2$ values captured by Random Forest for the training and testing datasets are $0.93$ and $0.53$, respectively; whereas, the worst performing model is introduced again by Linear-Lasso with $R^2$ values of $0.29$ for both training and testing datasets, respectively.

\subsubsection{25 Best}

We obtained similar results when building predictive models using the 25 best features. According to Figures \ref{fig:val:emo-rmse-25best} and \ref{fig:val:emo-r2-25best}, the best model achieving the lowest $RMSE$ values was Random Forest, with $RMSE$ values of $0.14$ and $0.37$ for both training and test datasets, respectively; whereas, the worst performing model is built by Linear-Lasso and SVR-Poly. The $RMSE$ values calculated by Linear-Lasso for training and testing datasets are $0.46$ and $0.47$, respectively. Furthermore, $RMSE$ values captured by SVR-Poly for training and testing datasets are $0.33$ and $0.67$, respectively.

A similar result is observed for $R^2$. The model built based on Random Forest provided the highest $R^2$ values for training and testing as $0.94$ and $0.59$, respectively. Whereas, the worst performing model is once again introduced by Linear-Lasso and SVR-Poly with $0.36$ and $0.66$ for training datasets, respectively. Moreover, the $R^2$ values for test datasets computed by Linear-Lasso and SVR-Poly are $0.35$ and $0.33$, respectively.

\subsubsection{All Features vs. PCA 90\% vs. 25 Best}

Looking at the performance of Random Forest-based prediction models depicted in Figure \ref{fig:val_allfeatures}, we notice that the performance of models based on all features and 25 best features are competitive and similar. As a result, we believe it would be a better option to build models based on a reduced set of acoustic features of 25 than building models based on all features.

In compliance with the results we obtained for predicting arousal, we observe that models based on Random Forest also outperformed other regression algorithms with a better accuracy for predicting valence. Therefore, in the following sections, we compare the performance of Random Forest models built using 25 best features in predicting arousal and valence and investigate how different or difficult it is to predict these two dimensions of emotion.

\subsection{Predicting Arousal vs. Valence}

Arousal and valence are the two primary dimensions of emotions and thus are utilized in building models. In other words, the better the prediction for arousal and valence, the more accurate model is achieved for emotion prediction perceived from sounds. Given the fact that the best models are built using Random Forest on top of 25 best features, we compared the performance of predicting arousal and valence using the prediction data captured by Random Forest using 25 best features. Figures \ref{fig:aro:emo-rmse-25best} and \ref{fig:aro:emo-r2-25best} illustrate the prediction accuracy for arousal using Random Forest and 25 best features; whereas, Figures \ref{fig:val:emo-rmse-25best} and \ref{fig:val:emo-r2-25best} depict the same metrics for valence.

As seen in the figures and evident from model fitting evaluation metrics, we were able to fit a slightly more accurate model for arousal than valence. The numerical values for $RMSE$ values for training and testing as well as for $R^2$ values for training and testing captured for arousal are $0.09$, $0.24$, $0.98$, and $0.84$. On the other hand, the $RMSE$ values for training and testing as well as for $R^2$ values for training and testing captured for valence are $0.14$, $0.37$, $0.94$, and $0.59$

Overall the $RMSE$ values are smaller for models built for predicting arousal while the $R^2$ values are greater than those computed for valence. The results indicate that fitting a good model and predicting valence is harder than building a good model for predicting arousal. The results make intuitive sense because modeling and predicting pleasures (i.e., valence) is much harder than modeling excitements (i.e., arousal)~\cite{Trochidis2013}. More specifically, it is hard to infer whether a sound expresses a positive or negative affect, but it is much easier to conclude that the sound is exciting or dull.

\begin{table}[htpb!]
      \begin{center}
\caption{The best and common features for arousal/valence.}
\begin{tabular}{|l|l|}
\hline
\multicolumn{1}{|c|}{\bf Arousal} & \multicolumn{1}{|c|}{\bf Valence} \\ \hline
\multicolumn{2}{|l|}{dynamics\_rms\_mean}                 \\ \hline
\multicolumn{2}{|l|}{dynamics\_rms\_std}                  \\ \hline
\multicolumn{2}{|l|}{rhythm\_fluctuationmax\_peakposmean} \\ \hline
\multicolumn{2}{|l|}{rhythm\_pulseclarity\_mean}          \\ \hline
\multicolumn{2}{|l|}{spectral\_centroid\_std}             \\ \hline
\multicolumn{2}{|l|}{spectral\_flatness\_mean}            \\ \hline
\multicolumn{2}{|l|}{spectral\_flatness\_std}             \\ \hline
\multicolumn{2}{|l|}{spectral\_irregularity\_mean}        \\ \hline
\multicolumn{2}{|l|}{spectral\_mfcc\_mean\_2}             \\ \hline
\multicolumn{2}{|l|}{spectral\_mfcc\_mean\_8}             \\ \hline
\multicolumn{2}{|l|}{spectral\_novelty\_mean}             \\ \hline
\multicolumn{2}{|l|}{spectral\_novelty\_std}              \\ \hline
\multicolumn{2}{|l|}{spectral\_rolloff85\_mean}           \\ \hline
\multicolumn{2}{|l|}{spectral\_rolloff85\_std}            \\ \hline
\multicolumn{2}{|l|}{spectral\_rolloff95\_mean}           \\ \hline
\multicolumn{2}{|l|}{spectral\_roughness\_mean}           \\ \hline
\multicolumn{2}{|l|}{spectral\_spread\_mean}              \\ \hline
\multicolumn{2}{|l|}{timbre\_lowenergy\_std}              \\ \hline
\multicolumn{2}{|l|}{timbre\_spectralflux\_mean}          \\ \hline
\multicolumn{2}{|l|}{timbre\_spectralflux\_std}           \\ \hline
spectral\_mfcc\_mean\_4     & spectral\_mfcc\_std\_4      \\ \hline
spectral\_mfcc\_std\_10     & spectral\_mfcc\_std\_6      \\ \hline
spectral\_mfcc\_std\_12     & spectral\_centroid\_mean    \\ \hline
spectral\_mfcc\_std\_13     & spectral\_kurtosis\_mean    \\ \hline
spectral\_spread\_std       & spectral\_kurtosis\_std     \\ \hline
timbre\_lowenergy\_mean     & spectral\_skewness\_mean    \\ \hline
                            & tonal\_hcdf\_mean           \\ \hline
                            & tonal\_mode\_std            \\ \hline
                            & rhythm\_tempo\_std          \\ \hline
\end{tabular}
\label{tab:bestfeatures}
 \end{center}
 \vspace{-0.2in}
\end{table}

\subsection{Exhaustive Search for Hyperparameter Tuning}
According to Figures \ref{fig:aro_allfeatures} and \ref{fig:val_allfeatures}, it is clear that the Random Forest outperforms other prediction models. Therefore, Random Forest was selected as the ultimate model to be tuned. Table \ref{tab:Exhaustive Search Results for the Best A/V Prediction} reports the results of tuning five parameters separately for arousal and valence predictions. The best test $RMSE$ value for arousal prediction is 0.25, which is captured using 26 Best features. These values are close to the results obtained by 25 Best features. Considering the valence prediction, the best performance achieved is 0.37 for $RMSE$ using 29 Best features. The 26 Best features for arousal prediction and 29 Best features for valence are reported in Table \ref{tab:bestfeatures}. It is noticeable that 20 features are common in best features for predicting arousal and valence.

\iffalse
\section{Application and Discussion}
\label{sec:discussion}

TBD.
\\Applications in The Internet of Things (IoT) and Cyber-Physical Systems (CPS)
\fi

\section{Conclusion and Future Work}
\label{sec:conclusion}

This paper focuses on emotions perceived from sounds and explores whether it is possible to predict perceived emotions accurately through machine learning algorithms. To do so, we extracted acoustic features of a given repository of sounds, called Emo-Soundscape, using the MATLAB MIRtoolbox. We then built regression-based machine learning models in which the acoustic features were utilized to build the models.

Exploring possible regression machine learning algorithms, we observed that ensemble-based learning and in particular Random Forest offer better predictions for both arousal and valence. More specifically, for predicting arousal and for training and testing datasets, we obtained $RMSE$ values of $0.09$ and $0.25$, respectively; whereas, for valence, the $RMSE$ values were $0.13$ and $0.37$ for training and testing datasets.

This study is the first step towards modeling emotions perceived from sounds and through arousal and valence. Additional studies are needed to investigate whether other types of sound features other than acoustic features, could be also useful for prediction purposes. Furthermore, this paper explored conventional machine learning algorithms. The emerging approaches in deep learning analysis might provide better predictions for perceived emotions.

\vspace{-0.05in}
\section*{Acknowledgment}
This research work is supported by National Science Foundation (NSF) under Grant No: 1564293.

\iffalse
\section*{Acknowledgment}
TBD.
\fi

\bibliographystyle{IEEEtran}

Sound (cs.SD); Computer Vision and Pattern Recognition (cs.CV); Audio and Speech Processing (eess.AS)


Storage of electrical energy: Batteries and Supercapacitors

Abstract: In this article we shall discuss the development of electrical storage system. Since the early days of electricity people have tried various methods to store electricity. One of the earliest device was a simple electrostatic capacitor that could store less than a micro Joule of energy. The battery has been the most popular in storing electricity as it has a higher energy density. We will discuss the development of batteries and their working principle. Although capacitors has never been thought of as a practical device for electricity storage, in the recent years there has been tremendous progress in building capacitors with huge capacitance and it may soon be possible to use it as storage device. We shall discuss the technological breakthroug in supercapacitor as a storage device.

\section*{Introduction}
Electricity was know to many cultures as a mysterous force of nature since ancient times. The first scientific study
was published only in 1600 by William Gilbert in "De Magnete" and until the begining of the ninteenth century any useful
application of electricity has not emerged. Today, we are all surrounded by huge number of devices
that uses electrical energy to work. In these devices energy is stored in batteries in the chemical bonds of
the materials that is cleverly chosen to make a battery. However, more than a hundred years ago, when
people were just begining to understand the nature of electricity with their intriguing experiments,
mostly on static electricity, a very simple and useful device was invented - the Leyden jar. It was the first
device that could store electrical energy. It consisted of a glass jar with conducting foil coated on the
inner and outer surface and a metal electrode connecting the inner foil that projects through the
stopper at the mouth cf. Fig. (\ref{leyden}). The capacitor that is manufactured today has fundmantally
the same designe except that it has become more efficient in storing energy. Today a capacitor can store
energy that is billions of times larger than that of a Leyden jar. How this has been achieved in the past
several decades is most fascinating. In the following we shall discuss about batteries and capacitors and their uses
in electrical energy storage. We will see, how nanotechnology has made possible the construction of capacitors
with very large capacitance called supercapacitors. With recent breakthrough in nanotechnology it appears that the
specific energy of supercapacitors may be comparable to certain batteries.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.2\textwidth]{leyden_jar1.eps}
    \includegraphics[width=0.2\textwidth]{leyden_jar.eps}
  \end{center}
  \caption{The Leyden jar: Invented by Ewald Georg von Kleist and Pieter van Musschenbroek in 1745-46. (source: wikipedia.org)}\label{leyden}
\end{figure}
\section{Electrochemical batteries}
Although, the term battery is used today for an electrochemical cell that converts chemical energy to electrical energy, it was actually
used for a combination of Leyden jars by Benjamin Franklin. The first electrochemical battery consisted of zinc and copper disks
separated by paper soaked in salt solution. It was invented by Alessandro Volta, a professor at University of Pavia, Italy in the year
1800. A stack of several disks arrange alternately provided a large potential difference. Unlike a Leyden jar it was a source of continuous
electrical current. It was also used to electrolyse water to obtain hyderogen and oxygen. The Voltaic pile is also sometime called the galvain
cell after its inventor Luigi Galvani who used it to contract frog's leg which he named "animal electricity". Volta however believed that the
that electricity arises from the contact of metal electrodes! It was only after 34 years when Michel Faraday showed that electricity was generated
at the electrode surface due to the oxidation and reduction reaction. In Fig. \ref{voltaic-pile} (a) is shown a replication of the voltaic pile. The
electrochemical processes in one of the cell is shown in the schematic Fig. \ref{voltaic-pile}(b).

Here we still haven't yet discussed why the reaction proceeds in the way it does.

\fbox{
\parbox[c]{10.0cm}{
~\\
{\bf Did you know?}\\
The energy consumption per capita in 2014 is 3.12 kW which is around three times that in the 1970 (cf. Fig. \ref{electricity}).
It simply means that every year the consumption incesases by 44 Wh for each person! As oil and coal reserve continue to deplete
and climate change becomes more severe we will be forced to use more renewable energy. In the next decade more people will be
using electricity than fossil fuel. Technologies in future will give more freedom to use electrical energy as cost of electricty will reduce.

It reminds us of Michael Faraday, when in 1859, was asked by William Gladstone, British chancellor of the exchequer, questioned the
usefulness of electricity, Faraday replied- "One day, sir, you may tax it."
~\\
}
}

\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.3\textwidth, angle=-90]{electricity3.eps}
  \end{center}
  \caption{World electricity consuption per capita (source: www.iea.org)}\label{electricity}
\end{figure}

\section{Spontaneity and the Gibbs free energy}
It is not difficult to witnessing a spontaneous process in nature. Water flowing down a stream or smoke rising up from a chimney
or the freezing of a lake during winter in cold contries are examples spontaneous processes.
Have you ever wondered how a spoonful of sugar added to a cup of water spontaneously dissolves and vanishes into the water in a few minutes?
It disolves because by doing so the system goes to a lower free energy state. The second law of thermodynamics demands that the entropy
of an isolated system always increases. Here, in this particular example the Gibbs free energy of the syestem decreases.
In all spontaneous processes that we observe, nature somehow tries to remain in the lowest free energy state.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.3\textwidth]{jwgibbs.eps}
  \end{center}
  \caption{Josiah Willard Gibbs (1839-1903), American theoretical physicist, one of the founders of statistical mechanics,
    introduced the concept of chemical potential.For a mixture of $N$ different species Gibbs gave a general
    expression for the change in energy $dE = T dS - pdV + \sum_i^N \mu_i dN_i$. The chemical potential $\mu_i = \partial E/\partial N_i$
    at constant entropy $S$, volume $V$ and particles $N_i$. Any open system undergoing a spontaneous process the Gibbs potential
    $G = H - TS$ attains a minimum. (source: wikipedia.org)}\label{jwgibbs}
\end{figure}

Consider a jar filled with white marbles upto say one third from the bottom and on top of it are filled up to the same height,
 black marbels. So we have black marbles on top of white marbles - a very ordered state.
Now shaking the jar well for some time will mix the marbels and we get a completely disordered state.
In going from an ordered state to a disordered state we have just increased the entropy, i.e., the change in entropy $\Delta S >0$.
At the molecular level, for the sugar molecules, the shaking is done by the thermal energy. The Gibb's free energy change of the system in
this example is  $\Delta G = - T \Delta S$ where $T$ is the temperature. In general the Gibbs free energy change
$\Delta G = \Delta H - T \Delta S$ where $\Delta H$ is the enthalpy or the heat absorbed at constant pressure.

A spontaneous process in general is given by a positive entropy change as demanded by the second law. From processes at  constant temperature and
at constant volume/pressure a spontaneous process may be defined by the Helmholtz and Gibbs free enargy change:
\begin{align}
\Delta F < 0,  \text{ ~~~~(at constant volume, temperature)},  \\
\Delta G < 0, \text{~~~~(at constant pressure, temperature)}.
\end{align}
At equilibrium the free energies attains a minima, hence $\Delta F =0$ and $\Delta G =0$ and there is positive free energy change for a non spontaneous
process.

Before the invention of his voltaic pile, Prof. Volta performed hundreds of experiments with different pairs of metals and found that when
two dissimilar metal pieces are brought in contact with each other the two metal pieces aquire opposite charges.  Although at that time it was not
know that it was the electron that moves from one metal to the other creating a charge imbalance. Note that we can see great similarities between
our marbels in the jar example and the electrons in the metals. The only difference here is that unlike marbles, electrons cannot be distinguish
with colors and they posses negative charge.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.15\textwidth]{voltaic_pile1.eps}
    \includegraphics[width=0.35\textwidth]{zn-cu.eps}
  \end{center}
  \caption{What goes on in a voltaic pile? : Copper has a higher electron affinity as compared to that of Zinc. Electrons rushes
    through the wire from zinc to copper. An electric field is produced inside the media which drives the positive ions towards
    the copper and negarive ions towards zinc. This results in the formation of zinc sulfate in the left half cell and deposition
    of copper on the electrode in the right half cell. The semipermiable membrane allows the passage of sulfate ion from the right
    to the left half cell. (voltaic pile, source: wikipedia.org)}\label{voltaic-pile}
\end{figure}
\section{How batteries work?}
Consider the zinc and copper electrodes in a voltaic pile. The copper has a free electron density of $n_{Cu} = 8.59 \times 10^{28} / \text{m}^3$
and that in zinc is $n_{Zn} = 1.31 \times 10^{29} / \text{m}^3$. It easy to find these densities simply by considering the a unit cell of zinc
and copper and the number of electrons in it that can contribute to an electrical current. If the electrons had no charge the electrons would
simply move from zinc to copper and there would be an equilibrium density of $1.08 \times 10^{29}$ electrons in each of the metal pieces. Due
to the charge transfer there develops a potential difference across the contact surfaces called the contact potential or the Volta potential.
Let us assume that $n$ electrons move from the zinc to the copper.  Since the free energy change at equilibrium
$\Delta G = \Delta E + \sum_i \mu_i \Delta N_i$ vanishes. The first term is the change in the internal energy due to the contact
potential and the second term is that due to the change in the number of particles of the $i^{th}$ species. Here, we just have one species
hence we should have, $0 = -en(\phi_{Cu} - \phi_{Zn}) + \mu_{Cu}n + \mu_{Zn}(-n)$. Note that $\Delta N$ is positive for copper and negative for Zinc.
Rearanging the terms gives us $\mu_{Cu} - e \phi_{Cu} = \mu_{Zn} - e \phi_{Zn}$. In general the following quantity may be constant across a contact surface
\begin{align}
\mu_0 + q \phi = \text{const},
\end{align}
where $\mu_0$ is the intrinsic chemical potential.

In the Voltaic pile there are two contact surfaces, i.e., the contact between the copper and the wet paper soaked in salt solution and similarly
between zinc and the wet paper. We know a salt solution does not conduct electricity by the free movement of electrons but instead it conducts by
oppositely moving ions. To understand how this happens we have a simplified Voltaic cell in Fig. \ref{voltaic-pile} (b). It consists of a the zinc
and copper electrode in zinc sulfate and copper sulfate solution which is separated by a semipermiable membrane in the middle which allows the
passage of sulfate ions only. As we saw earlier zinc loses a electrons through the wire and acquires a positive charge while copper electrod accepts
those electrons and becomes negatively charge. In the left and the right half cells we have the following reactions
 %
\begin{align}
Cu \rightarrow Cu^{2+}  + 2e^{-}, ~~~E^0 = 0.36 V, \nonumber \\
Zn \rightarrow Zn^{2+}  + 2e^{-},~~~ E^0 = -0.76 V. \nonumber
\end{align}
The negatively charged copper electrodes attracts $Cu^{2+}$ in the copper electrode and the $SO_4^{2-}$ sulfate ions get attracted towards the
positive charged zinc electrode. As a result zinc sulfate, $ZnSO_4$, is formed in the left half cell and $Cu$ is deposited on the right electrode.
Of course there has to be a movement on a sulfate ion pass through the membrane to balance the total charge to zero. In this process zinc is
oxidized by losing two electrons and copper is reduced by gaining the same number of electrons. This is called a redox reaction. The potential
difference can be obtained from the standard electrode potentials $E^0$of zinc and copper. i.e. from the half reaction described
above the we have $E_{cell} = E^0_{red} - E^0_{ox} =0.34 - (-0.76) = 1.10 V$. The change in free energy $\Delta G = -n F E_{cell}$ where
$n=2$ is the number of moles of electrons transfered, $F = 98654$ Coulombs charge in a unit mole of electrons is the Faraday constant.
So the amount of energy stored in a battery which has anode and cathode weighing 65 g and the solution has 1 molar
concentration of the salts will be $2.17 \times 10^{5}J$.

The Voltaic cell was a milestone in technological advancment. It started a new branch in chemistry-electrochemistry. Within months of the
invention of the invention of Voltaic pile several discoveries were made such as the splitting of water into hydrogen and oxygen, and the
isolation of varous alkali metals.
\section{The rechargable battery}
The Voltaic cell is a one time use battery as the zinc electrode is consumed its potential drops to zero. This kind of cells are called primary cells.
In 1859, the French physicist Gaston Plant\'{e} invented the first rechargable battery, the lead-acid battery. After the battery is drained out applying
a voltage with opposite polarity recharges the battery again. These kind of batteries are called secondary batteries.  To understand the working of a
Lead acid battery we need to look at the redox reaction that takes place on the electrode surfaces during the charging and the recharging process.
During the discharging process we have
\begin{align}
Anode: & Pb(s) + H_2SO_{4}(aq) \rightarrow PbSO_4(s) + 2H^{+}(aq) + 2e−, \nonumber \\
Cathode: & PbO_2 + 2H^{+} + H_2SO_4 + 2e^{-} \rightarrow PbSO_4(s) + 2H_2O(l). \nonumber
\end{align}
The working of a lead acid battery is show in Fig. \ref{lead-acid}. Note that during the dischrging process the lead-acid battery acts just a
voltaic cell where lead is oxidized at the anode and lead oxide is reduced at the cathode to form lead sulfate.
During the recharging process the opposite reaction takes place and the lead sulfate converts back to lead and lead oxide electrodes.
From the standard electrode potential we obtain a cell potential of $E_{cell} = 2.04$ Volts.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.5\textwidth]{lead-acid.eps}
  \end{center}
\caption{Working of a lead acid battery. Discharging cycle(left), and Charging cycle (right).}\label{lead-acid}
\end{figure}
The lead acid brought a revolution is electrical storage device. Today there are a various other rechargable batteries in use. The lithium-ion
battery is the most advanced with the highest energy density. Although its devlopment goes back to the seventies, the first commercial battery
were introduced in 1991 by Sony and Asahi Kasei \cite{lib}. There are several types of lithium ion batteries such as lithium cobalt oxide (LiCO$_2$),
lithium manganese oxide (LiMn$_2$O$_4$, Li$_2$MnO$_3$), lithium nickel cobalt manganese oxide (LiNiMnCoO$_2$), lithium iron phosphate (LiFePO$_4$),
etc. The specific energy varries from 100-265 Wh/kg. In the lithium ion batteries the lithium ions move from the cathode to the anode and
vice versa during the charging and discharging cycle in a reversible process. Due to this mechanism of the lithium ions moving back and forth
it is called "rocking chair" battery.  In general we can represent the over all process by
\begin{align}
Li_x A + B \leftrightarrow Li_{x-y}A + Li_y B,
\end{align}
where Li$_x$ A is a compound that can readily accept and exchange lithium ions and B is another lithium accepting compound \cite{scrosati}.
Here the process going from left to right represent discharging and the reverse process represents charging cycle.

There are various other rechargable batteries with varied specific energies\cite{shukla, shukla2}. Lithium ion has one of the highest
specific energies in electrical energy storage system.

\section{What are supercapacitors?}
A typical supercapacitor may have a capacity of $100-1000$ Farad. Now, it is important to first understand how large is a Farad?
Let's construct a capacitor with this aluminium foil of area $10 \times 10 \text{cm}^2$ as electrodes separated by a piece of paper.
If we connect the electrodes to a battery charge ($Q$) will be accumulated on the foils which is equal to the capacitance ($C$) times
the applied potential difference ($V$). The capacitance of this capacitor is $C = \epsilon_r \epsilon_0 A/d$ where $A$ is the area of the foil, $d$ is
thickness of the paper, $\epsilon_r$ is the dielectric constant and $\epsilon_0 = 8.85 \times 10^{-12} F/m^2$. Assuming that the paper
 has a dielectric constant $\epsilon_r = 2.5$ and thickness $d = 0.01 \text{mm}$ the capacitance can be computed to be
$C = 2.2 \times 10^{-9} $ Farad or $C = 2.2$ nano Farad (nF). This is the capacitance of a typical Leyden jar! Charging it with a
$V = 12$ Volt battery will therefore store energy $E = C V^2/2 = 0.16 \times 10^{-6}$ Joules of energy. Note that the energy
stored in a capacitor is proportional to the square of the potential difference. Now to understand how big or small $0.16 \times 10^{-6} J$
 is lets consider a rubber band of length $l=10 cm$ and see how much energy is required to stretch it by 10 cm. The spring constant can be obtained
 by using the Hooke's law which says that stress ($\sigma$) is equal to the Youngs modulus ($Y$) times the strain ($\epsilon$) in a material, i.e.,
 $\sigma = Y \epsilon$. Lets assume that the rubber band has a diameter $d = 1$ mm and we have $Y = 0.0015$ giga Pascal
 \footnote{1 Pascal = 1 Newton/meter$^2$}, then the spring constant $k = Y A/l = 0.0015 \times 10^6 \pi d^2/ l  = 0.015 \pi$ Newton/meter.
 The energy stored in a spring which is stretched by an ammount $x$ in length is $E = k x^2/2$. So if we stretch the rubberband by $x = 1$ cm we
 require energy $E = 0.015 \pi (10^{-2})^2/2 = 0.23 \times 10^{-5}$ Joules. This is around ten times more energy that was stored in the Leyden jar.
 In other words we will need ten Leyden jar to stretch a rubber band by one centemeter!

 Our comparision of the energy stored is a capacitor with that of a battery tells us that  to use capacitors for electrical storage we need huge
 capacitance. The capacitance can be increased in two ways, one by increasing the area of the electrodes and two by increasing the dielectric constant.
 In the recent years there has been so much excitement and hope in utilizing the former by the use of advanced material such as graphene. We shall
 come back to it later but first see how a supercapacitor works. In 1957, H. Becker registered the first patent of an electrolytic supercapacitor that
 was constructed by the use of porous carbon electrodes and an electrolyte. It had a capacitance of around 6 Farad which he had no idea what gave rise
 to such a huge capacitance \cite{conway}. It was of course due to the large srface area of the electrodes that were responsibly for the rise in
 capacitance. However, the working of a supercapacitor is slightly different from that of the electrostatic capacitor. In Fig. \ref{edlc} we have a
 simple design of a supercapacitor. I consists of two electrodes with large surface areas usually made of carbon based materials such as activated
 charcoal, graphene, carbon nanotubes or a combinations of the three. In between that electrodes there there is an electrolyte and a porous membrane
 which allows the passage of ions. The porous electrode is in contact with a current collector usually metallic that has high electrical conductivity.
 When the electrodes of the capacitor is connected to an external source positive and negative ions in the electrolyte move in the opposite directions.
 They are accumulated on an electric double layer on the porous electrodes. The double layer consists of electrons and holes on the prorous carbon
 and oppositely charged ions on the surface separated by a thin layer of the solvent molecules. Now as we discussed earlier that the capacitance
 $C$ is inversely proportional to the distance $d$ between the electrodes i.e. $C =\epsilon_r \epsilon_0 A/d$, here we have a think monolayer separating
 the charges we have $d$ of the order of nanometers. This gives rise to a huge capacitance! This kind of capacitors are called the electric double layer
 capacitor.

 Unlike batteries which can be charged and discharged for 1000 - 1500 times the supercapacitors practically lasts for ever since it has a
 charge-discharge cycle of $10^6$. The power density of a capacitor is also enormous due to very low equivalent series resistance which remains
 contant during discharge. Such large cycle is not possible in batteries since the electrodes degrade due to the redox reactions with every charge
 discharge cycle. Although the electric double layer capacitor stores energy by a completely non-Faradaic process there are however other kinds of
 capacitor called pseudocapacitors which utilizes a Faradaic charge transfere by the use of transition metal oxides such as RuO$_2$, IrO$_2$, FeO$4$,
and MnO$_2$, titanium sulfides TiS$_2$. The specific capacitance of pseudocapacitors if larger than that of the electric double
layer capacitors but it has a lower specific power density. A list of commercially available supercapacitors may be found in \cite{scap}.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.5\textwidth]{edlc.eps}
  \end{center}
\caption{Constriction of a spercapacitor.}\label{edlc}
\end{figure}
\section{Graphene in supercapacitors}
In the last couple of decades there has been tremendous progress in our understanding of the microscopic world.
Graphene is a atomically thin two dimensional sheet of carbon. It was discovered by Andre Geim and Kostantin Novoselov
at the University of Manchester, UK in 2004 \cite{novo}. It consists of $sp^2$ bonded carbon atoms in a hexagonal lattice structure.
It has exquisit electrical, thermal and mechanical properties. The surface area of one gram of graphene is 2630 $m^2$ and
has excellent electrical conductivity. Theoretically the capacitance of a graphene based supercapacitor is 550 F/g. Almost all the
supercapacitor available in the market uses some form of carbon based electrode with large surface area.
There is tremendous research in progress to achieve higher specific energy by using graphene based supercapacitors \cite{YuBin}.

\section{Present status of electrical storage device}
In Fig. \ref{ragone}, we have a comparision of various kinds of electrical storage devices. The Lithium ion batteries has the highest specific
energy of around of around 100-250 Wh/kg with a cycle life of around 1000 cycle. The Lead acid battery on the has a specific energy of
30-40 Wh/kg \footnote{1 Wh = 3600 J} and remain in use and has one of the highest power density. Of all the batteries sold today the
lead acid battery comprises around one half due to its cheaper raw materials and simpler technology. Recently the specific energy of supercapacitors
appears to have reached an equivalent of the lead acid battery however it does not have long self life and hence cannot be used in place of the
lead-acid batteries. However supercapacitor has been in use for in {\it capabus} in various countries that uses supercapacitor to store energy.
At every stop the bus stops for a few minutes while the pasanger board/unboard it charges it supercapacitors through the charging point
immediately. This energy is sufficient to run a few mile till it reaches the next bus stop. This technology has been used in Switzerland, Germany,
UK, US and China. The technology is remarkable not oly because it is greener but also its uses almost
half the energy required the capacitors have made the bus lighter.

If we look at rechargable batteries that were used a decade ago we can recall that it took an awfull lot of time to recharge. Today the rechargable
batteries are equiped with supercapacitors that enables it to charge is few minutes. These are call the hybrid batteries that uses a battery coupled to
a supercapacitor. Interestingly, one of the earliest battery that used this technique is the hybrid lead acid battery, developed by CSIRO, Australia
in 2007. In China the CSR Zhuzhou Electric Locomotive has built a prototype of a light metro train that uses supercapacitors to run and uses no
other power supply \cite{csrz}.
\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.6\textwidth]{rag.eps}
  \end{center}
\caption{Ragone plot: comparision of energy storage devices. (source: wikipedia.org)}\label{ragone}
\end{figure}
\section{Technologies to come in future}
The future of electrical storage devices looks not very coherent at the present time. Several promising
ideas is currently being pursued by researches around the world.
Even at present the Li ion battery is many fold expensive as compared other alternatives. In the immediate
future what we may see is a more powerful lithium battery.
In this direction the technolology that could soon become a reality is the lithium-sulfur battery which
has a specific energy density as high as 500 Wh/kg. Recently, researchers
at the University of Alberta, Canada, have developed a silicon and graphene based lithium cell that has
a tenfold higher capacity than the currently available lithium batteries \cite{LiSi}.
It would be essential to have technilogy that is not only advanced as well as affordaable. The sodium ion
battery looks very promising as it has a large cycle life of 2000 cycles although
the specific energy is low.

Supercapacitors on the other hand will make possible technologies in the areas of wearable electronics,
energy scavenging, energy storage for microscopic machines and fast charging hybrid battery systems.
In a recent paper \cite{nitin} structural composites using reinforced carbon nanotubes electric double
layer capacitor were proposed which has multiple functionalality. Similarly, supercapacitors that can
charge itself with the sun light has been reported which uses a graphene silver 3D foam electrodes \cite{libu}.

\begin{figure}[!h]
  \begin{center}
    \includegraphics[width=0.5\textwidth]{plant-e.eps}
  \end{center}
\caption{Plant mictobial fuel cell (source: Wageningen  University \& Research).}\label{pmfc}
\end{figure}
\fbox{
\noindent
\parbox[c]{10cm}{
~\\
{\bf Did you know?}\\
~\\
The bacteria present in the soil can be used to produce electricity. In 1911, M. C. Potter a professor in botany at the University of Durham,
used  S. cerevisiae a kind of yeast used in winemaking
to generate electricity and in 1931, B. Cohen constructed a microbial half cell that could generate 35 Volts with although a very small
current of 2 miliAmpere \cite{microbial}. Recently scientists at the  Wageningen University
and the Wageningen Research foundation, had designed a plant microbian fuel cell called plant-e, produces electricity from plants
\cite{plant-e}. The fuel cell work by using the mutual cooperation of bacteria present in the soil and the
plants (cf. Fig. \ref{pmfc}).
~\\
}
}

\section*{Acknowledgement}
AMJ thanks DST, India for financial support (through J. C. Bose National Fellowship).