projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check token type before trying to match tokid. Fixes PR 12923.
[pspp]
/
src
/
factor_stats.c
diff --git
a/src/factor_stats.c
b/src/factor_stats.c
index 8109a2171f0774f25a3087ab156e0f40af475d03..4508caf889c3c4eceed0756a048089ddb688043c 100644
(file)
--- a/
src/factor_stats.c
+++ b/
src/factor_stats.c
@@
-15,8
+15,8
@@
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 5
9 Temple Place - Suite 330
, Boston, MA
-0211
1-1307
, USA. */
+Foundation, Inc., 5
1 Franklin Street, Fifth Floor
, Boston, MA
+0211
0-1301
, USA. */
#include "factor_stats.h"
#include "config.h"
#include "factor_stats.h"
#include "config.h"
@@
-44,6
+44,7
@@
metrics_precalc(struct metrics *m)
m->min = DBL_MAX;
m->max = -DBL_MAX;
m->min = DBL_MAX;
m->max = -DBL_MAX;
+ m->histogram = 0;
m->moments = moments1_create(MOMENT_KURTOSIS);
m->moments = moments1_create(MOMENT_KURTOSIS);
@@
-141,6
+142,13
@@
metrics_postcalc(struct metrics *m)
m->wvp = (struct weighted_value **) hsh_sort(m->ordered_data);
m->n_data = hsh_count(m->ordered_data);
m->wvp = (struct weighted_value **) hsh_sort(m->ordered_data);
m->n_data = hsh_count(m->ordered_data);
+ /* Trimmed mean calculation */
+ if ( m->n_data <= 1 )
+ {
+ m->trimmed_mean = m->mean;
+ return;
+ }
+
m->histogram = histogram_create(10, m->min, m->max);
for ( i = 0 ; i < m->n_data ; ++i )
m->histogram = histogram_create(10, m->min, m->max);
for ( i = 0 ; i < m->n_data ; ++i )
@@
-149,13
+157,6
@@
metrics_postcalc(struct metrics *m)
gsl_histogram_accumulate(m->histogram, wv[i]->v.f, wv[i]->w);
}
gsl_histogram_accumulate(m->histogram, wv[i]->v.f, wv[i]->w);
}
- /* Trimmed mean calculation */
- if ( m->n_data <= 1 )
- {
- m->trimmed_mean = m->mean;
- return;
- }
-
tc = m->n * 0.05 ;
k1 = -1;
k2 = -1;
tc = m->n * 0.05 ;
k1 = -1;
k2 = -1;
@@
-272,7
+273,8
@@
metrics_destroy(struct metrics *m)
{
hsh_destroy(m->ordered_data);
hsh_destroy(m->ptile_hash);
{
hsh_destroy(m->ordered_data);
hsh_destroy(m->ptile_hash);
- gsl_histogram_free(m->histogram);
+ if ( m-> histogram )
+ gsl_histogram_free(m->histogram);
}
void
}
void