Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
a319729c
Commit
a319729c
authored
Jul 13, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug in height of quantile for histo superposition
parent
99f83d7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
13 deletions
+25
-13
include/Algo/Histogram/histogram.h
include/Algo/Histogram/histogram.h
+3
-3
src/Algo/Histogram/histogram.cpp
src/Algo/Histogram/histogram.cpp
+22
-10
No files found.
include/Algo/Histogram/histogram.h
View file @
a319729c
...
...
@@ -168,9 +168,11 @@ class Histogram
/// get idx of data in attribute
unsigned
int
idx
(
unsigned
int
i
)
const
;
// comparison function for sorting data
//
/
comparison function for sorting data
static
bool
dataComp
(
const
std
::
pair
<
double
,
unsigned
int
>&
a
,
const
std
::
pair
<
double
,
unsigned
int
>&
b
);
/// update quantiles height from histo area for correct superposition
void
quantilesAreaCorrection
();
public:
/**
...
...
@@ -178,7 +180,6 @@ public:
*/
Histogram
(
HistoColorMap
&
hcm
);
/**
* init data
* @param conv a attribute convertor
...
...
@@ -348,7 +349,6 @@ public:
*/
const
HistoColorMap
&
colorMap
()
const
;
};
...
...
src/Algo/Histogram/histogram.cpp
View file @
a319729c
...
...
@@ -87,6 +87,11 @@ void Histogram::populateHisto(unsigned int nbclasses)
if
(
m_populations
[
i
]
>
m_maxBar
)
m_maxBar
=
m_populations
[
i
];
}
// apply area correction on quantile if necessary
if
(
m_pop_quantiles
.
size
()
!=
0
)
quantilesAreaCorrection
();
}
void
Histogram
::
populateQuantiles
(
unsigned
int
nbquantiles
)
...
...
@@ -121,21 +126,30 @@ void Histogram::populateQuantiles(unsigned int nbquantiles)
val
=
m_dataIdx
.
back
().
first
;
m_interv
.
push_back
(
val
);
}
quantilesAreaCorrection
();
}
m_maxQBar
=
0.0
;
// constant area correction
double
lc
=
1.0
f
;
void
Histogram
::
quantilesAreaCorrection
()
{
unsigned
int
nbquantiles
=
m_pop_quantiles
.
size
();
if
(
m_nbclasses
!=
0
)
//for histo superposition
lc
=
double
(
m_dataIdx
.
back
().
first
-
m_dataIdx
.
front
().
first
)
/
double
(
m_nbclasses
);
// constant area correction
double
areaQ1
=
100.0
f
;
// use 100 as area if no histogram
if
(
m_nbclasses
!=
0
)
{
double
areaH
=
(
getMax
()
-
getMin
())
/
double
(
m_nbclasses
)
*
double
(
m_dataIdx
.
size
());
areaQ1
=
areaH
/
nbquantiles
;
// area of one quantile
}
m_maxQBar
=
0.0
;
for
(
unsigned
int
i
=
0
;
i
<
nbquantiles
;
++
i
)
{
double
lq
=
m_interv
[
i
+
1
]
-
m_interv
[
i
];
m_pop_quantiles
[
i
]
=
m_pop_quantiles
[
i
]
*
lc
/
lq
;
// compute height instead of population
double
lq
=
m_interv
[
i
+
1
]
-
m_interv
[
i
];
// width
m_pop_quantiles
[
i
]
=
areaQ1
/
lq
;
// height = area / width
if
(
m_pop_quantiles
[
i
]
>
m_maxQBar
)
m_maxQBar
=
m_pop_quantiles
[
i
];
m_maxQBar
=
m_pop_quantiles
[
i
];
// store max
}
}
...
...
@@ -202,8 +216,6 @@ unsigned int Histogram::cellsOfQuantilesColumn( unsigned int c, std::vector<unsi
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment