2 #include "ui_statsdialog.h" 22 QDialog::showEvent(ev);
28 QDialog::closeEvent(ev);
34 data_keys_ = matrix_keys;
35 if (isVisible()) UpdateDisplayData();
41 data_keys_ = QStringList();
49 if (!data_keys_.size())
return;
50 if (data_keys_.first() == name){
51 data_keys_ = QStringList();
56 double StatsDialog::CalculateMedian()
58 const mat& data = workspace_->GetMatrix(data_keys_);
59 if (!data.n_elem)
return 0;
60 if (data.n_cols == 1)
return as_scalar(median(data));
63 data_copy.reshape(data.n_elem, 1);
64 return as_scalar(median(data_copy));
70 double StatsDialog::CalculateStdDev()
72 const mat& data = workspace_->GetMatrix(data_keys_);
73 if (!data.n_elem)
return 0;
74 if (data.n_cols == 1)
return as_scalar(stddev(data));
77 data_copy.reshape(data.n_elem, 1);
78 return as_scalar(stddev(data_copy));
83 double StatsDialog::CalculateMean()
85 const mat& data = workspace_->GetMatrix(data_keys_);
86 if (!data.n_elem)
return 0;
87 if (data.n_cols == 1)
return as_scalar(mean(data));
90 data_copy.reshape(data.n_elem, 1);
91 return as_scalar(mean(data_copy));
96 void StatsDialog::GenerateHistogram()
98 ui->histogramCustomPlot->clearPlottables();
99 const mat& data = workspace_->GetMatrix(data_keys_);
100 if (!data.n_elem)
return;
103 edges.shed_row(edges.n_rows - 1);
105 qvec histq = qvec::fromStdVector(conv_to<stdvec>::from(hist));
106 qvec edgesq = qvec::fromStdVector(conv_to<stdvec>::from(edges));
109 ui->histogramCustomPlot->yAxis);
110 hist_plot->
addData(edgesq, histq);
111 hist_plot->
setWidth(edges(1) - edges(0));
112 edgesq.append(data.max());
113 QVector<QString> labels;
114 for (
auto value: edgesq) labels << QString::number(value,
'g', 3);
115 ui->histogramCustomPlot->addPlottable(hist_plot);
116 ui->histogramCustomPlot->xAxis->setTickVector(edgesq);
117 ui->histogramCustomPlot->xAxis->setTickVectorLabels(labels);
118 ui->histogramCustomPlot->rescaleAxes();
119 ui->histogramCustomPlot->replot();
122 void StatsDialog::UpdateDisplayData()
124 if (data_keys_.size() < 2) ClearFields();
127 const mat& data = workspace_->GetMatrix(data_keys_);
132 ui->minLineEdit->setText(QString::number(data.min()));
133 ui->maxLineEdit->setText(QString::number(data.max()));
134 ui->medLineEdit->setText(QString::number(CalculateMedian()));
135 ui->stddevLineEdit->setText(QString::number(CalculateStdDev()));
136 ui->meanLineEdit->setText(QString::number(CalculateMean()));
137 ui->nameLabel->setText(data_keys_.last());
138 QString dimensions = QString::number(data.n_rows) +
"×" + QString::number(data.n_cols);
139 ui->dimensionLabel->setText(dimensions);
140 ui->plottableLabel->setText(workspace_->Plottable(data_keys_) ?
"True" :
"False");
141 ui->mappableLabel->setText(workspace_->Mappable(data_keys_) ?
"True" :
"False");
144 void StatsDialog::CalculateCI()
146 const mat& data = workspace_->GetMatrix(data_keys_);
147 if (!data.n_elem)
return;
148 double alpha = ui->alphaDoubleSpinBox->value();
149 double stddev = CalculateStdDev();
150 unsigned int n = data.n_elem;
152 ui->confidenceLineEdit->setText(QString::number(w));
156 void StatsDialog::on_calculatePushButton_clicked()
161 void StatsDialog::ClearFields()
163 ui->minLineEdit->setText(
"NA");
164 ui->maxLineEdit->setText(
"NA");
165 ui->medLineEdit->setText(
"NA");
166 ui->stddevLineEdit->setText(
"NA");
167 ui->meanLineEdit->setText(
"NA");
168 ui->nameLabel->setText(
"No matrix selected");
169 ui->dimensionLabel->setText(
"NA");
170 ui->plottableLabel->setText(
"NA");
171 ui->mappableLabel->setText(
"NA");
172 ui->confidenceLineEdit->setText(
"NA");
173 ui->histogramCustomPlot->clearPlottables();
174 ui->histogramCustomPlot->replot();
VESPUCCI_EXPORT arma::uvec GenerateHistogram(const arma::mat &data, arma::vec &edges, uint bins=0)
void closeEvent(QCloseEvent *ev)
A plottable representing a bar chart in a plot.
StatsDialog(MainWindow *parent, QSharedPointer< VespucciWorkspace > ws)
void setWidth(double width)
VESPUCCI_EXPORT double TInterval(double alpha, double stddev, unsigned int n)
Vespucci::Math::Stats::TInterval.
void MatrixToBeRemoved(QStringList matrix_keys)
void showEvent(QShowEvent *ev)
void MatrixSelectionChanged(QStringList matrix_keys)
cmplx FADDEEVA() w(cmplx z, double relerr)
bool KeysAreEqual(QStringList &keys1, QStringList &keys2)
void addData(const QCPBarDataMap &dataMap)
void SetActionChecked(bool checked)
The MainWindow class The main window of the program, this is where the user performs most operations...
void DatasetToBeRemoved(QString name)