Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated DistrModeler Class #1

Open
wants to merge 224 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
224 commits
Select commit Hold shift + click to select a range
c77a1ea
cleanup
chunmingchen Jun 13, 2016
135ac6e
Remove vtk and visualization parts to simplify edda core library
chunmingchen Jun 13, 2016
5c67d8f
update documents
chunmingchen Jun 13, 2016
c0d6fc1
add random sampling codes
chunmingchen Jun 14, 2016
c78ba3b
modification for windows
chunmingchen Jun 15, 2016
b0f005a
mod for windows
chunmingchen Jun 15, 2016
a5b1d72
cmath support for visual studio
chunmingchen Jun 16, 2016
6da5107
update on visual studio support
chunmingchen Jun 16, 2016
b136ca7
Add histogram classes to fill. increase stability.
chunmingchen Jun 18, 2016
65d930f
First add converter
subhashis Jun 27, 2016
2daf9df
Minor update for windows compatibility
chunmingchen Jun 30, 2016
3bc6c70
changed a few #ifndef of .h files
ChengLiOSU Jun 30, 2016
0b5cbd4
Merge pull request #1 from ChengLiOSU/master
chunmingchen Jun 30, 2016
9ccdeb3
merge edda_vis back. rename Distribution base class to DistributionTag
chunmingchen Jul 2, 2016
5f2fc94
minor change and bug fix
chunmingchen Jul 2, 2016
0b9f9ef
add distribution virtual class
chunmingchen Jul 2, 2016
8b58c12
Add examples
chunmingchen Jul 5, 2016
6dc447c
initial commit for distribution data modeler.
subhashis Jul 5, 2016
59c15b4
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 5, 2016
40b081a
bug fix
chunmingchen Jul 5, 2016
2755a38
Merge pull request #2 from subhashis/master
chunmingchen Jul 5, 2016
804514d
change abstract_data_array name to abstract_distr_array. change data…
chunmingchen Jul 9, 2016
6791f97
add missing files
chunmingchen Jul 9, 2016
947bb3b
add the 1D histogram modeling and functions in histogram.h
caseywang777 Jul 10, 2016
0555d5a
Merge pull request #3 from caseywang777/master
chunmingchen Jul 10, 2016
4b31fb1
Modify edda vtk reader. Add edda vtk writer.
chunmingchen Jul 10, 2016
2853a51
Merge branch 'master' of https://github.com/GRAVITYLab/edda
chunmingchen Jul 10, 2016
d8bf909
commit these two files only for passing the comiple and github merge
caseywang777 Jul 10, 2016
3eea636
Merge branch 'master' of https://github.com/GRAVITYLab/edda
caseywang777 Jul 10, 2016
8c7f1f2
support GaussianMixture of 1-5 Gaussian models
chunmingchen Jul 10, 2016
4b2a155
created distr_modeler class and adding Soumya's estimate_gmm.h
subhashis Jul 11, 2016
e88057a
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 11, 2016
994f2b4
updated DistrModeler Class with API to read .nc files after Jimmy's A…
subhashis Jul 11, 2016
4bb2573
Prepare curvilinear grids for Cheng's integration
chunmingchen Jul 11, 2016
b79ab88
curvilinear grid init
ChengLiOSU Jul 12, 2016
86baa52
pull origin solve conflict
ChengLiOSU Jul 12, 2016
e98803b
further solve conflict
ChengLiOSU Jul 12, 2016
b1b314c
curvilinear basically work
ChengLiOSU Jul 13, 2016
7b7561e
removing cmakelist message()
subhashis Jul 14, 2016
9b49678
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 14, 2016
50ebd25
Merge pull request #4 from subhashis/master
chunmingchen Jul 14, 2016
e6f741c
copyright comment on soumya's api
subhashis Jul 14, 2016
63ee595
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 14, 2016
c3e51c1
minor update for estimate_gmm.h
chunmingchen Jul 14, 2016
f83e8a2
Merge pull request #5 from subhashis/master
chunmingchen Jul 14, 2016
302814e
cmakelist temp update
subhashis Jul 14, 2016
2b84346
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 14, 2016
a779fae
cahnges in distr_modeler class to handle different types of distribution
subhashis Jul 17, 2016
4bd05c8
Merge pull request #6 from subhashis/master
chunmingchen Jul 18, 2016
5538df7
Remove unused CMake symbol
chunmingchen Jul 18, 2016
c2de679
finish curvilinear grid
ChengLiOSU Jul 18, 2016
2a7d95a
Merge branch 'master' of https://github.com/ChengLiOSU/edda
chunmingchen Jul 19, 2016
987ddfc
Minor changes for curvilinear grid integration
chunmingchen Jul 19, 2016
05791c2
Fix for distribution query in dataset
chunmingchen Jul 19, 2016
47e3935
update the reader and writer for histogram
caseywang777 Jul 22, 2016
27d3cfc
remove some printf() which prints the debug information to myself
caseywang777 Jul 22, 2016
d33e6c2
Merge remote-tracking branch 'upstream/master'
caseywang777 Jul 22, 2016
b571d34
add test_histogram_io
caseywang777 Jul 22, 2016
8f2ffb0
Merge pull request #8 from caseywang777/master
chunmingchen Jul 22, 2016
65df230
initial commit after including Histogram data-structure
subhashis Jul 22, 2016
38dd641
Merge pull request #9 from subhashis/master
chunmingchen Jul 22, 2016
d98e1f8
initialization of the histogram in distr_modeler
subhashis Jul 23, 2016
f29792f
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 23, 2016
5066eb8
test curvilinear data sampling at a cross section
ChengLiOSU Jul 24, 2016
08aa4df
in histogram modeling, add the function of detecting min,max value range
caseywang777 Jul 24, 2016
162d60e
Merge pull request #11 from caseywang777/master
chunmingchen Jul 25, 2016
1cba869
support modeling and saving non-default gaussian mixture models.
chunmingchen Jul 25, 2016
ce56a04
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 25, 2016
bdf8aa0
minor modification
ChengLiOSU Jul 25, 2016
d7e79bb
Merge remote-tracking branch 'upstream/master'
ChengLiOSU Jul 25, 2016
36aafe5
fix curvilinear grids reader in edda vtk reader
chunmingchen Jul 25, 2016
21040c8
Merge remote-tracking branch 'upstream/master'
ChengLiOSU Jul 25, 2016
c895e91
Spatial Decomposition in distr_modeler and added independent example …
subhashis Jul 26, 2016
1a532b5
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 26, 2016
f654dff
Merge pull request #10 from subhashis/master
subhashis Jul 26, 2016
d7ffa1a
cmakelist cleanup
subhashis Jul 26, 2016
f24977e
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jul 26, 2016
421686a
Merge pull request #12 from subhashis/master
subhashis Jul 26, 2016
cfc3698
change large 2d array to pointer
ChengLiOSU Jul 26, 2016
8419d0b
update gaussian mixture sampling routine to better handle cases when …
chunmingchen Jul 26, 2016
0f120c1
add GMM weights normalization when loading data
ChengLiOSU Jul 26, 2016
62b7197
solve conflict
ChengLiOSU Jul 26, 2016
05fcea5
Demonstration for histogram dataset
chunmingchen Jul 27, 2016
2ade084
improve curvilinear grid
ChengLiOSU Jul 28, 2016
1a16af6
change by the discussion oin 20160728 meeting
caseywang777 Jul 28, 2016
4d44cc0
Merge remote-tracking branch 'upstream/master'
caseywang777 Jul 28, 2016
7affcdf
Merge pull request #14 from caseywang777/master
chunmingchen Jul 29, 2016
620e8bd
Merge pull request #13 from ChengLiOSU/master
chunmingchen Jul 29, 2016
2310b03
Merge branch 'master' of https://github.com/GRAVITYLab/edda
chunmingchen Aug 1, 2016
ec8a519
Minor update for Demo
chunmingchen Aug 1, 2016
c7ca544
update new test_histogram_io example
caseywang777 Aug 4, 2016
9770a12
Merge remote-tracking branch 'upstream/master'
caseywang777 Aug 4, 2016
6c9e60e
Add joint distribution support and JointGaussian prototype
chunmingchen Aug 5, 2016
8b2c5d5
rename AbstractDistrArray to DistrArray, and original DistrArray to S…
chunmingchen Aug 5, 2016
cafb73f
nothing change
caseywang777 Aug 5, 2016
b1b2b70
Merge remote-tracking branch 'upstream/master'
caseywang777 Aug 5, 2016
239b7ac
Add JointHistogram implementation and an image processing test case f…
Junpengw Sep 2, 2016
b379040
start edda writer
ChengLiOSU Sep 18, 2016
7426b22
1. add the new distribution type Joint_GMM which includes joint_gauss…
caseywang777 Oct 10, 2016
caf82c9
Merge remote-tracking branch 'upstream/master'
caseywang777 Oct 10, 2016
6806d52
Merge pull request #15 from caseywang777/master
caseywang777 Oct 10, 2016
070fada
1.add readme&license in Eigen Library folder
caseywang777 Oct 18, 2016
0a4240a
Merge pull request #16 from caseywang777/master
caseywang777 Oct 18, 2016
d3ef70b
basic edda i/o for GMM on Regular Cartesian
ChengLiOSU Oct 19, 2016
229808c
Merge remote-tracking branch 'upstream/master'
ChengLiOSU Oct 19, 2016
d91858a
new distribution modeler with user defined data partitioning.
subhashis Oct 19, 2016
82feb1e
removing old distr modeler files
subhashis Oct 19, 2016
c395996
Merge pull request #17 from subhashis/master
subhashis Oct 19, 2016
eb48dfc
i/o for scalar histogram at Regular Cartesian
ChengLiOSU Oct 20, 2016
42fda01
Merge pull request #18 from ChengLiOSU/master
ChengLiOSU Oct 20, 2016
2f565cc
modify according to meeting feedback
ChengLiOSU Oct 30, 2016
3858f32
edda file format: support and test of GMM vector3
ChengLiOSU Nov 9, 2016
99ff6bd
Merge pull request #19 from ChengLiOSU/master
ChengLiOSU Nov 10, 2016
0e174b7
Vector data modeling
subhashis Nov 13, 2016
b7e880a
Merge pull request #20 from subhashis/master
subhashis Nov 13, 2016
338b5be
Change input sample format for the eddaComputeJointGMM(Joint_GMM.h)
caseywang777 Nov 15, 2016
4b3938b
Merge remote-tracking branch 'upstream/master'
caseywang777 Nov 15, 2016
f8587df
Merge pull request #21 from caseywang777/master
caseywang777 Nov 15, 2016
c7082e9
remove the inverse of covariance matrix, add comments for doxygen
Junpengw Nov 15, 2016
79ca906
Update doxygen (code comments) files
Junpengw Nov 15, 2016
576c189
add the uni-variate GMM without template
caseywang777 Dec 30, 2016
cc3d6cb
Merge remote-tracking branch 'upstream/master'
caseywang777 Dec 30, 2016
ba0dd83
Merge pull request #23 from caseywang777/master
caseywang777 Dec 30, 2016
5f64a67
updating checkin
subhashis Jan 8, 2017
ed58dd7
Merge branch 'master' of https://github.com/gravitylab/edda
subhashis Jan 8, 2017
f540ca8
new distribution modeler in src/distribution.
subhashis Jan 8, 2017
3120c48
Merge pull request #24 from subhashis/master
subhashis Jan 8, 2017
696ccc1
remove distr_modeler folder
subhashis Jan 8, 2017
9b7033e
updatinf cmake to remove distr_modeler directory
subhashis Jan 8, 2017
8828e41
Merge pull request #25 from subhashis/master
subhashis Jan 8, 2017
9f5f8de
bug fix in CMakefile
caseywang777 Jan 12, 2017
c48cebf
Merge pull request #26 from caseywang777/master
caseywang777 Jan 12, 2017
c72b3e1
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Jan 25, 2017
64ce7e1
put the operators function back (gaussian.h)
caseywang777 Jan 27, 2017
fb6d865
Merge remote-tracking branch 'upstream/master'
caseywang777 Jan 27, 2017
2428960
Merge pull request #27 from caseywang777/master
caseywang777 Jan 27, 2017
c469e55
reader/writer for scalar GMM
ChengLiOSU Jan 27, 2017
9ded5bf
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Jan 27, 2017
6021d9a
Merge pull request #28 from ChengLiOSU/master
ChengLiOSU Jan 27, 2017
e37b239
add an example of uncertain isocontour without using vtk
Junpengw Feb 1, 2017
d6ad35a
scalar histogram is done
ChengLiOSU Feb 1, 2017
3148e75
Merge branch 'master' of https://github.com/GRAVITYLab/edda
ChengLiOSU Feb 1, 2017
d79ee2a
restore distrModelerExample; add scalarIOExample
ChengLiOSU Feb 2, 2017
282a3c2
vecter IO and example
ChengLiOSU Feb 3, 2017
a999671
minor fix
ChengLiOSU Feb 7, 2017
e4c8968
Update README.md
Junpeng-Wang Feb 8, 2017
8344641
Minor fix for test_jointGMM.cpp
caseywang777 Aug 18, 2017
45b8bf5
Merge branch 'master' of https://github.com/caseywang777/edda
caseywang777 Aug 18, 2017
812a3fd
Fix typo in test_jointGMM.cpp
caseywang777 Aug 18, 2017
66e92f3
Fix matrix acess bug in JointGMM training
caseywang777 Oct 4, 2017
83fda39
Merge pull request #29 from caseywang777/master
caseywang777 Oct 4, 2017
21c1817
Remove .vscode generated by my local editor and not related to EDDA
caseywang777 Oct 18, 2017
2ab3376
Merge pull request #30 from caseywang777/master
caseywang777 Oct 18, 2017
2b35624
Merge pull request #1 from GRAVITYLab/master
subhashis Oct 19, 2017
6b5a666
remove old VTK IO part
ChengLiOSU Oct 23, 2017
ae6b382
Merge branch 'master' into master
ChengLiOSU Oct 23, 2017
7ec7313
Merge pull request #31 from ChengLiOSU/master
ChengLiOSU Oct 23, 2017
7f50868
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Oct 23, 2017
e82e8bc
update
subhashis Oct 23, 2017
6d6d5b4
Merge pull request #32 from subhashis/master
subhashis Oct 23, 2017
dbac521
Merge pull request #2 from GRAVITYLab/master
subhashis Oct 23, 2017
b1a477a
change the string -> %s error
ChengLiOSU Oct 23, 2017
8ec5387
Merge pull request #33 from ChengLiOSU/master
ChengLiOSU Oct 23, 2017
638511d
Merge branch 'master' of https://github.com/GRAVITYLab/edda
subhashis Oct 23, 2017
773af52
Add maximum limite for EM iterations to single variate GMM training (…
caseywang777 Oct 24, 2017
340dc5b
Merge branch 'master' of https://github.com/GRAVITYLab/edda
caseywang777 Oct 24, 2017
bc23d15
Merge pull request #34 from caseywang777/master
caseywang777 Oct 24, 2017
3f0d4a5
Adding the examples for multivariate datamodeler
subhashis Oct 25, 2017
2e860f7
Merge branch 'master' of https://github.com/GRAVITYLab/edda
subhashis Oct 25, 2017
e7c7372
Merge pull request #36 from subhashis/master
subhashis Oct 25, 2017
a456de8
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Oct 25, 2017
b66d190
temp jointGMM io with error in the example file
ChengLiOSU Oct 25, 2017
5165345
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Oct 25, 2017
bf86793
temporary test version, with error in edda_reader
ChengLiOSU Oct 27, 2017
068a0a6
IO for joint GMM and joint Histogram
ChengLiOSU Oct 29, 2017
781d3db
Merge pull request #38 from ChengLiOSU/master
ChengLiOSU Oct 29, 2017
4b02d3a
Merge remote-tracking branch 'refs/remotes/GRAVITYLab/master'
ChengLiOSU Oct 30, 2017
ec63d7b
changeing the distribution array type from ScalarDistArray to jointDi…
subhashis Nov 2, 2017
590339a
Merge branch 'master' of https://github.com/GRAVITYLab/edda
subhashis Nov 2, 2017
8f324a3
Merge pull request #39 from subhashis/master
subhashis Nov 2, 2017
65eb5e0
fixing indentations
subhashis Nov 2, 2017
a1640be
Merge branch 'master' of https://github.com/GRAVITYLab/edda
subhashis Nov 2, 2017
0b3ed8d
Merge pull request #40 from subhashis/master
subhashis Nov 2, 2017
a7a9b7b
Add note on parameters and functions for doxygen (JointGMM, GMM and H…
caseywang777 Nov 13, 2017
3f29dff
Fix minor bug
caseywang777 Nov 13, 2017
9838c0a
Merge branch 'master' of https://github.com/GRAVITYLab/edda
caseywang777 Nov 13, 2017
fef5b10
Merge pull request #41 from caseywang777/master
caseywang777 Nov 13, 2017
4214863
[pyEdda] adding pyEdda subproject
subhashis Jan 19, 2018
3caa271
including .gitmodules
subhashis Jan 19, 2018
6baed9c
changing .gitmodule to include pybind11 submodule
subhashis Jan 19, 2018
98ca084
Merge pull request #42 from subhashis/master
subhashis Jan 19, 2018
173fe20
[pyEdda] repository cloning information
subhashis Jan 19, 2018
d7fb258
Merge branch 'master' of https://github.com/GRAVITYLab/edda
subhashis Jan 19, 2018
44927e9
Merge pull request #43 from subhashis/master
subhashis Jan 19, 2018
52a369f
Merge remote-tracking branch 'upstream/master'
ChengLiOSU Jan 20, 2018
fa114d2
remove vtk for non-vis; add comments for IO
ChengLiOSU Jan 21, 2018
cae170d
Merge remote-tracking branch 'upstream/master'
ChengLiOSU Jan 21, 2018
51bdf0c
modify a bug on linux of edda_reader
ChengLiOSU Jan 22, 2018
d202c5b
Merge pull request #44 from ChengLiOSU/master
ChengLiOSU Jan 22, 2018
5428c75
1. Add python wrapper for univariate histogram, gaussian, gmm
caseywang777 Jan 24, 2018
3c70cd5
Merge pull request #45 from caseywang777/master
caseywang777 Jan 24, 2018
8c29138
pyEdda for Visual Studio; IO classes
ChengLiOSU Jan 25, 2018
51c8fac
Merge pull request #46 from ChengLiOSU/master
ChengLiOSU Jan 25, 2018
18a8259
Add missing file(py_gaussian.h)
caseywang777 Jan 26, 2018
0270ff9
Merge pull request #47 from caseywang777/master
caseywang777 Jan 26, 2018
6eaf6ce
fit change of getNumComponenets()
ChengLiOSU Jan 28, 2018
25deffd
Merge pull request #48 from ChengLiOSU/master
ChengLiOSU Jan 28, 2018
9bd74c0
try to resolve the extra qualification issue
ChengLiOSU Jan 31, 2018
6ccaa7f
Merge pull request #49 from ChengLiOSU/master
ChengLiOSU Jan 31, 2018
6981c75
try to resolve the extra qualification issue - complementary
ChengLiOSU Jan 31, 2018
3af12a6
Merge pull request #50 from ChengLiOSU/master
ChengLiOSU Jan 31, 2018
4538515
test on Linux, fixed a bug in EddaWriter
Junpengw Jan 31, 2018
46b7876
working on wrapping JointHistogram
Junpengw Feb 2, 2018
4383b5c
finish the wrapping of JointHistogram class
Junpengw Feb 5, 2018
2bdc66d
remove Thrust in JointGaussian, JointGMM
Junpengw Feb 5, 2018
256470e
wrap JointGaussian, need eddaComputeJointGaussian to finish the corre…
Junpengw Feb 6, 2018
12a2ddb
Add 1. eddaComputeJointGaussian to JointGaussian 2. JointGaussian Test
caseywang777 Feb 9, 2018
c30a1fe
Add comment into test_jointGaussian
caseywang777 Feb 14, 2018
5ff01e6
Merge pull request #57 from caseywang777/master
caseywang777 Feb 14, 2018
5441b95
update univariate GMM testing, change double in estimate_gmm to Real
caseywang777 Feb 14, 2018
a956aea
Separate pyedda's univariate distribution's test code
caseywang777 Feb 14, 2018
474519b
Merge pull request #58 from caseywang777/master
caseywang777 Feb 14, 2018
1887ab1
improve the jointGMM and add new test case.
caseywang777 Jun 19, 2018
2acd003
Merge pull request #59 from caseywang777/master
caseywang777 Jun 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyEdda/py_gmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ class PyGMM {
gmm = new GMM(c_Models);
}

PyGMM(py::array_t<double> data, int GMs)
PyGMM(py::array_t<Real> data, int GMs)
{
//first convert the numpy array (data) to a pointer of array to be passed to the c++ functions
py::buffer_info info = data.request();
auto ptr = static_cast<double *>(info.ptr);
auto ptr = static_cast<Real *>(info.ptr);

//Check the input numpy array's dimensionality
int ndim = info.ndim;
Expand Down
52 changes: 0 additions & 52 deletions pyEdda/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,3 @@
print (r3)
print (r4)
print()

#Univariate histogram
print("//////////Univariate Histogram///////")
dummy_data = np.random.rand(100)
hist = edda.Histogram(dummy_data, 10)
print ("hist.getMean():", hist.getMean())
histCopy = edda.Histogram(hist)
print("histCopy.getMean():", histCopy.getMean())
print("hist.getVar():", hist.getVar())
print("hist.getPdf(0.5):",hist.getPdf(0.5))
print("hist.getCdf(1.0):",hist.getCdf(1.0))
print("hist.getSample():", hist.getSample())
print("Output histogram:")
hist.output()
print("hist.getBins():", hist.getBins())
print("hist.getMaxValue():", hist.getMaxValue())
print("hist.getMinValue():", hist.getMinValue())
print("hist.getBinValue(3):", hist.getBinValue(3))
print()

#Univariate Gaussian
print("//////////Univariate Gaussian///////")
dummy_data = np.random.rand(100)
gaussian = edda.Gaussian(100, 20)
print("gaussian.getMean():", gaussian.getMean())
print("gaussian.getVar():", gaussian.getVar())
print("gaussian.getPdf(105):", gaussian.getPdf(105))
print("gaussian.getSample():", gaussian.getSample())
print("gaussian.getCdf(105):", gaussian.getCdf(105))
print("gaussian.getCdfPrecise():", gaussian.getCdfPrecise(105))
print("Output gaussian:")
gaussian.output()
print()

#Univariate GMM
print("//////////Univariate GMM///////")
gmm = edda.GMM(4)
models = np.array([[0.2, 10, 2],[0.5, 15, 4],[0.1, 8, 7],[0.2,6, 9]])
gmm = edda.GMM(models)
print("gmm.getNumComponents():", gmm.getNumComponents() )
print("gmm.getMean():", gmm.getMean())
print("gmm.getVar():", gmm.getVar())
print("gmm.getPdf(10):", gmm.getPdf(10))
print("gmm.getSample():", gmm.getSample())
print("gaussian.getCdf(10):", gmm.getCdf(10))
print("Output GMM:")
gmm.output()
print("Model and output a gmm by trainig samples:")
dummy_data = np.random.rand(100)
modelGmm = edda.GMM(dummy_data,3)
modelGmm.output()
print()
19 changes: 19 additions & 0 deletions pyEdda/test_uni_gaussian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#make print in python 2, 3 compatible
from __future__ import print_function
import numpy as np
import pyedda as edda


#Univariate Gaussian
print("//////////Univariate Gaussian///////")
dummy_data = np.random.rand(100)
gaussian = edda.Gaussian(100, 20)
print("gaussian.getMean():", gaussian.getMean())
print("gaussian.getVar():", gaussian.getVar())
print("gaussian.getPdf(105):", gaussian.getPdf(105))
print("gaussian.getSample():", gaussian.getSample())
print("gaussian.getCdf(105):", gaussian.getCdf(105))
print("gaussian.getCdfPrecise():", gaussian.getCdfPrecise(105))
print("Output gaussian:")
gaussian.output()
print()
23 changes: 23 additions & 0 deletions pyEdda/test_uni_gmm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#make print in python 2, 3 compatible
from __future__ import print_function
import numpy as np
import pyedda as edda

#Univariate GMM
print("//////////Univariate GMM///////")
gmm = edda.GMM(4)
models = np.array([[0.2, 10, 2],[0.5, 15, 4],[0.1, 8, 7],[0.2,6, 9]])
gmm = edda.GMM(models)
print("gmm.getNumComponents():", gmm.getNumComponents() )
print("gmm.getMean():", gmm.getMean())
print("gmm.getVar():", gmm.getVar())
print("gmm.getPdf(10):", gmm.getPdf(10))
print("gmm.getSample():", gmm.getSample())
print("gaussian.getCdf(10):", gmm.getCdf(10))
print("Output GMM:")
gmm.output()
print("Model and output a gmm by trainig samples:")
dummy_data = np.random.rand(100)
modelGmm = edda.GMM(dummy_data,3)
modelGmm.output()
print()
23 changes: 23 additions & 0 deletions pyEdda/test_uni_histogram.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#make print in python 2, 3 compatible
from __future__ import print_function
import numpy as np
import pyedda as edda

#Univariate histogram
print("//////////Univariate Histogram///////")
dummy_data = np.random.rand(100)
hist = edda.Histogram(dummy_data, 10)
print ("hist.getMean():", hist.getMean())
histCopy = edda.Histogram(hist)
print("histCopy.getMean():", histCopy.getMean())
print("hist.getVar():", hist.getVar())
print("hist.getPdf(0.5):",hist.getPdf(0.5))
print("hist.getCdf(1.0):",hist.getCdf(1.0))
print("hist.getSample():", hist.getSample())
print("Output histogram:")
hist.output()
print("hist.getBins():", hist.getBins())
print("hist.getMaxValue():", hist.getMaxValue())
print("hist.getMinValue():", hist.getMinValue())
print("hist.getBinValue(3):", hist.getBinValue(3))
print()
6 changes: 3 additions & 3 deletions src/distributions/distribution_modeler.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class DistributionModeler {
void computeGMM(float *data, size_t size, size_t nGmm, size_t index)
{
//TODO: check for out of bound errors.
double *dataD;
dataD = new double[size];
Real *dataD;
dataD = new Real[size];

for(size_t i=0; i<size; i++)
dataD[i] = (double) data[i];
dataD[i] = (Real) data[i];

dist::GMM new_distr;
new_distr = eddaComputeGMM(dataD, size, nGmm);
Expand Down
82 changes: 41 additions & 41 deletions src/distributions/estimate_gmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace edda
///////////////////////////////////////////
/// \brief EM helper function
///
inline int check_convergence(double fmax, double fmin, double ftol)
inline int check_convergence(Real fmax, Real fmin, Real ftol)
{
double EPS = 1e-10;
double delta = fabs(fmax - fmin);
double accuracy = (fabs(fmax) + fabs(fmin)) * ftol;
Real EPS = 1e-10;
Real delta = fabs(fmax - fmin);
Real accuracy = (fabs(fmax) + fabs(fmin)) * ftol;
return (delta < (accuracy + EPS));
}

Expand All @@ -37,11 +37,11 @@ inline int check_convergence(double fmax, double fmin, double ftol)
/// \mean mean of a Gaussian
/// \sigma sigma of a Gaussian
/// \val given sample value
inline double eval_gaussian_density(double mean, double sigma, double val)
inline Real eval_gaussian_density(Real mean, Real sigma, Real val)
{
double EPS = 1e-10;
double prob=0.0;
double exponent=0.0;
Real EPS = 1e-10;
Real prob=0.0;
Real exponent=0.0;

if(sigma>0)
{
Expand All @@ -62,9 +62,9 @@ inline double eval_gaussian_density(double mean, double sigma, double val)

///////////////////////////////////////////
/// \brief Upate parameter of a Gaussian
inline void update_parameters(int n, double * data, int k, double * prob, double * mean, double * sd, double ** class_prob)
inline void update_parameters(int n, Real * data, int k, Real * prob, Real * mean, Real * sd, Real ** class_prob)
{
double EPS = 1e-6;
Real EPS = 1e-6;

//Update weights first
for (int j = 0; j < k; j++)
Expand Down Expand Up @@ -99,11 +99,11 @@ inline void update_parameters(int n, double * data, int k, double * prob, double

///////////////////////////////////////////
/// EM helper function
inline double classprob(int j, double x, int k, double *prob, double *mean, double *sd)
inline Real classprob(int j, Real x, int k, Real *prob, Real *mean, Real *sd)
{
double num = prob[j]*eval_gaussian_density(mean[j],sd[j],x);
Real num = prob[j]*eval_gaussian_density(mean[j],sd[j],x);

double denom=0;
Real denom=0;
for(int i=0;i<k;i++)
denom += prob[i]*eval_gaussian_density(mean[i],sd[i],x);

Expand All @@ -112,7 +112,7 @@ inline double classprob(int j, double x, int k, double *prob, double *mean, doub

///////////////////////////////////////////
/// EM helper function
inline void update_class_prob(int n, double * data, int k, double * prob, double * mean, double * sd, double ** class_prob)
inline void update_class_prob(int n, Real * data, int k, Real * prob, Real * mean, Real * sd, Real ** class_prob)
{
int i, j;
for (i = 0; i < n; i++)
Expand All @@ -122,13 +122,13 @@ inline void update_class_prob(int n, double * data, int k, double * prob, double

///////////////////////////////////////////
/// EM helper function
inline double computeLogLikelihood(int n, double* data,int k, double* prob,double* mean,double* sd)
inline Real computeLogLikelihood(int n, Real* data,int k, Real* prob,Real* mean,Real* sd)
{
double llk=0;
Real llk=0;

for(int p=0;p<n;p++)
{
double val=0;
Real val=0;
for(int q=0;q<k;q++)
{
val += prob[q]*eval_gaussian_density(mean[q],sd[q],data[p]);
Expand All @@ -144,9 +144,9 @@ inline double computeLogLikelihood(int n, double* data,int k, double* prob,doubl
//////////////////////////////////////////////
/// Main EM function
///
inline dist::GMM eddaComputeGMM(double *dataArray, int nSamples, int nComps)
inline dist::GMM eddaComputeGMM(Real *dataArray, int nSamples, int nComps)
{
double eps = 1e-6;
Real eps = 1e-6;
int GMMs = nComps;

if (nSamples<GMMs)
Expand All @@ -157,23 +157,23 @@ inline dist::GMM eddaComputeGMM(double *dataArray, int nSamples, int nComps)
}
else
{
double llk = 0, prev_llk = 0;
double *mean, *sd, *weight;
double **class_prob;
Real llk = 0, prev_llk = 0;
Real *mean, *sd, *weight;
Real **class_prob;

//Allocate memories for computation
/////////////////////////////////////////////////////////////
class_prob = (double **)malloc(sizeof(double *)*nSamples);
class_prob = (Real **)malloc(sizeof(Real *)*nSamples);
for (int i = 0; i<nSamples; i++)
class_prob[i] = (double *)malloc(sizeof(double)* GMMs);
class_prob[i] = (Real *)malloc(sizeof(Real)* GMMs);

mean = (double *)malloc(sizeof(double)* GMMs);
sd = (double *)malloc(sizeof(double)* GMMs);
weight = (double *)malloc(sizeof(double)* GMMs);
mean = (Real *)malloc(sizeof(Real)* GMMs);
sd = (Real *)malloc(sizeof(Real)* GMMs);
weight = (Real *)malloc(sizeof(Real)* GMMs);

//initial estimate of parameters
/////////////////////////////////////////////
double mean1 = 0.0, sd1 = 0.0;
Real mean1 = 0.0, sd1 = 0.0;

for (int i = 0; i < nSamples; i++)
mean1 += dataArray[i];
Expand Down Expand Up @@ -236,9 +236,9 @@ inline dist::GMM eddaComputeGMM(double *dataArray, int nSamples, int nComps)
/// Main EM function
///
template <int GMMs>
void eddaComputeEM(double *samples, int numSamples, dist::GaussianMixture<GMMs>* new_gmm)
void eddaComputeEM(Real *samples, int numSamples, dist::GaussianMixture<GMMs>* new_gmm)
{
double eps = 1e-6;
Real eps = 1e-6;

if(numSamples<GMMs)
{
Expand All @@ -247,23 +247,23 @@ void eddaComputeEM(double *samples, int numSamples, dist::GaussianMixture<GMMs>*
}
else
{
double llk = 0, prev_llk = 0;
double *mean,*sd,*weight;
double **class_prob;
Real llk = 0, prev_llk = 0;
Real *mean,*sd,*weight;
Real **class_prob;

//Allocate memories for computation
/////////////////////////////////////////////////////////////
class_prob = (double **) malloc(sizeof(double *)*numSamples);
class_prob = (Real **) malloc(sizeof(Real *)*numSamples);
for(int i=0;i<numSamples;i++)
class_prob[i] = (double *) malloc(sizeof(double) * GMMs);
class_prob[i] = (Real *) malloc(sizeof(Real) * GMMs);

mean = (double *) malloc(sizeof(double) * GMMs);
sd = (double *) malloc(sizeof(double) * GMMs);
weight = (double *) malloc(sizeof(double) * GMMs);
mean = (Real *) malloc(sizeof(Real) * GMMs);
sd = (Real *) malloc(sizeof(Real) * GMMs);
weight = (Real *) malloc(sizeof(Real) * GMMs);

//initial estimate of parameters
/////////////////////////////////////////////
double mean1 = 0.0, sd1 = 0.0;
Real mean1 = 0.0, sd1 = 0.0;

for (int i = 0; i < numSamples; i++)
mean1 += samples[i];
Expand Down Expand Up @@ -326,7 +326,7 @@ void eddaComputeEM(double *samples, int numSamples, dist::GaussianMixture<GMMs>*
///////////////////////////////////////////
/// Incremental update helper function
template <int GMMs>
bool testforMatch(double val, dist::GaussianMixture<GMMs>* currentGMM, std::vector<float> *valList, std::vector<float> *distList)
bool testforMatch(Real val, dist::GaussianMixture<GMMs>* currentGMM, std::vector<float> *valList, std::vector<float> *distList)
{
float sigmaTh = 2.0;
int match=0;
Expand Down Expand Up @@ -359,7 +359,7 @@ bool testforMatch(double val, dist::GaussianMixture<GMMs>* currentGMM, std::vect
/// Main Incremental GMM update function
///
template <int GMMs>
void eddaUpdateGMMIncremental(double *samples, int numSamples, dist::GaussianMixture<GMMs>* new_gmm)
void eddaUpdateGMMIncremental(Real *samples, int numSamples, dist::GaussianMixture<GMMs>* new_gmm)
{
float alpha = 0.2;//Mixing rate in updation

Expand Down
Loading