MATH-816
Using different seeds for the component distributions to avoid getting the same sequence of random numbers for all of them. Update to the "testSampling" unit test contributed by Jared Becksfort. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1401894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5765cf99d
commit
e0426dfbfb
|
@ -140,9 +140,8 @@ public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistr
|
|||
|
||||
for (int i = 0; i < distribution.size(); i++) {
|
||||
// Make each component's seed different in order to avoid
|
||||
// using the same sequence of random numbers. XXX
|
||||
// components.get(i).reseedRandomGenerator(i + 1 + seed);
|
||||
distribution.get(i).reseedRandomGenerator(seed); // XXX original code.
|
||||
// using the same sequence of random numbers.
|
||||
distribution.get(i).reseedRandomGenerator(i + 1 + seed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,125 +165,124 @@ public class MultivariateNormalMixtureModelDistributionTest {
|
|||
* Values used in {@link #testSampling()}.
|
||||
*/
|
||||
private double[][] getCorrectSamples() {
|
||||
// These were sampled from the MultivariateNormalMixtureModel class
|
||||
// with seed 50. They were then fit to a MVN mixture model in R
|
||||
// using mixtools. The fitted parameters were:
|
||||
// These were sampled from the MultivariateNormalMixtureModelDistribution class
|
||||
// with seed 50.
|
||||
//
|
||||
// - component weights: {0.3730363, 0.6269637}
|
||||
// - mean vectors: {-1.760221, 2.080246}, {4.042673 8.239901}
|
||||
// They were then fit to a MVN mixture model in R using mixtools.
|
||||
//
|
||||
// The optimal parameters were:
|
||||
// - component weights: {0.3595186, 0.6404814}
|
||||
// - mean vectors: {-1.645879, 1.989797}, {3.474328, 7.782232}
|
||||
// - covariance matrices:
|
||||
// {2.343314 -1.161423
|
||||
// -1.161423 2.168186},
|
||||
// {4.538306 1.999180
|
||||
// 1.999180 3.707478}
|
||||
// { 1.397738 -1.167732
|
||||
// -1.167732 1.801782 }
|
||||
// and
|
||||
// { 3.934593 2.354787
|
||||
// 2.354787 4.428024 }
|
||||
//
|
||||
// These parameters are quite close to the given test parameters,
|
||||
// considering that the sample size is only 100. This indicates that
|
||||
// we are sampling from the given distributions correctly.
|
||||
//
|
||||
// MVN mixture model fitting is tested more directly in
|
||||
// MultivariateNormalMixtureModelEMTest.java.
|
||||
// It is considered fairly close to the actual test parameters,
|
||||
// considering that the sample size is only 100.
|
||||
return new double[][] {
|
||||
{ 0.2583074099703975, 8.664499710373795 },
|
||||
{ -4.813531184031044, 3.9231359989545105 },
|
||||
{ -0.7419261132564453, 2.4007823469659315 },
|
||||
{ 5.509216904195162, 9.422233433392439 },
|
||||
{ -2.381049190850173, 4.943660886154495 },
|
||||
{ -0.8993376528270461, 0.8938743025320182 },
|
||||
{ 4.894770663858121, 12.166851725156436 },
|
||||
{ 4.0897683028395075, 6.918843155044206 },
|
||||
{ 4.719618558675267, 8.341707066796028 },
|
||||
{ 5.0119792918378385, 8.718202270235704 },
|
||||
{ -0.9575382403048307, 1.8229677546531289 },
|
||||
{ 6.096419130934251, 10.015298483992137 },
|
||||
{ -0.8680257551663279, 2.017226810559624 },
|
||||
{ 1.5561509591914775, 6.428382522063888 },
|
||||
{ 2.9573609580937585, 4.984112447026558 },
|
||||
{ 2.9607883517629716, 5.040859511876173 },
|
||||
{ 6.693223483958679, 8.293058555022974 },
|
||||
{ -0.49520319305205684, 2.654804424012847 },
|
||||
{ 2.5982446884625903, 4.403704372523807 },
|
||||
{ -2.8126962615987825, 1.524225284837275 },
|
||||
{ 4.617557399108285, 10.112045833514983 },
|
||||
{ -1.0505336217175474, -0.25620619814406176 },
|
||||
{ 6.468546093824413, 8.492764345471349 },
|
||||
{ -1.070959919055369, -0.21025004020250515 },
|
||||
{ 0.7096492923917137, 0.972470062045611 },
|
||||
{ 5.398941052924385, 9.02323432480054 },
|
||||
{ 4.0619884910872885, 3.9387544688324274 },
|
||||
{ 3.060654105075946, 8.375879742835302 },
|
||||
{ -1.1120837945401831, -0.5932624462175884 },
|
||||
{ 1.7076086958821626, 10.076176310641726 },
|
||||
{ 0.8025522475696087, 7.376934311816509 },
|
||||
{ -1.7692026721062535, 3.342422431805849 },
|
||||
{ 6.347756985325947, 9.473453725270733 },
|
||||
{ 5.881105197046502, 7.489181251843213 },
|
||||
{ 1.2360421752575719, 6.795186398153966 },
|
||||
{ 0.4401756166827726, 1.2313491852695706 },
|
||||
{ 2.3000936045037568, 8.287718300406317 },
|
||||
{ -0.670230868276056, 2.1130200354211004 },
|
||||
{ 0.3003945370882637, -1.5819884144799348 },
|
||||
{ 7.277242408774614, 10.927490482503183 },
|
||||
{ 7.923140481277026, 12.004508589648411 },
|
||||
{ 5.522112916642092, 9.78447909183086 },
|
||||
{ 1.7119808481577339, 6.085145192818114 },
|
||||
{ 2.105629604263621, 10.1449475519281 },
|
||||
{ 4.972245882289706, 9.190876138075419 },
|
||||
{ 3.55810426807224, 7.654818193514658 },
|
||||
{ -2.356177988964854, 2.532266732955841 },
|
||||
{ -4.1832049468547385, 4.506619880263655 },
|
||||
{ -3.830920610669877, 2.6251612200440366 },
|
||||
{ -0.06307681885555017, 2.099426408596512 },
|
||||
{ 0.36171488935238116, 0.6347956010120039 },
|
||||
{ 4.151714086462804, 8.647657431234045 },
|
||||
{ 0.7057392641959304, 6.692562958393579 },
|
||||
{ -0.6550353398872, 7.692019868324891 },
|
||||
{ 4.320276127581665, 7.202292152597195 },
|
||||
{ -3.2303904191995527, 1.961730492225101 },
|
||||
{ -2.954784139519494, 2.7707906587677087 },
|
||||
{ 4.467020781304962, 11.98783401317258 },
|
||||
{ 2.516614661485048, 5.7484664274488395 },
|
||||
{ 0.5769047448998346, 5.631710672821962 },
|
||||
{ 0.1160140182849414, 2.9315783896969196 },
|
||||
{ 2.5049583778078652, 8.761243869910377 },
|
||||
{ 5.709406025351957, 8.257826327804949 },
|
||||
{ 0.21312967519917736, 3.5654341612096037 },
|
||||
{ 3.6569574551599913, 5.771827106887553 },
|
||||
{ -0.8798149482991884, 2.6978303136418855 },
|
||||
{ 2.414118561546714, 4.53422981267982 },
|
||||
{ 1.4898922645162216, 7.761630474438329 },
|
||||
{ -2.541784545189355, 1.1738033253079712 },
|
||||
{ -3.879227113624057, 4.4006851836938345 },
|
||||
{ 6.661993934276366, 7.141516646050444 },
|
||||
{ 3.181178356801352, 8.231063903955624 },
|
||||
{ 1.8841679086668033, 7.8838333882950895 },
|
||||
{ -1.0951561728318044, 2.4280383085698944 },
|
||||
{ 5.35219559310147, 10.747404919992816 },
|
||||
{ 6.960010647189781, 6.95945895094293 },
|
||||
{ 8.66048279380016, 10.240215090544776 },
|
||||
{ 5.322414316267673, 11.183073632332036 },
|
||||
{ 4.286246289231014, 9.881220496364916 },
|
||||
{ 3.1594608386471306, 7.472785192202438 },
|
||||
{ 7.490325449520623, 9.327482647357861 },
|
||||
{ -1.6450957033850353, 1.7263141708037384 },
|
||||
{ 7.640267915158525, 9.040106401524124 },
|
||||
{ 3.225359471647853, 7.698098961183428 },
|
||||
{ 5.511639004578083, 9.186863380867411 },
|
||||
{ -1.5570773470706916, 2.3113691458388006 },
|
||||
{ 3.6254977322201625, 8.605119642693507 },
|
||||
{ 6.825831664908241, 8.090893354857114 },
|
||||
{ 4.614281342893763, 9.430714925646987 },
|
||||
{ 3.244449074987682, 7.4974070774986705 },
|
||||
{ -3.630882697488002, 2.0936948617188036 },
|
||||
{ 4.668632614740622, 9.56561505235852 },
|
||||
{ 3.291602850422323, 7.676202933382092 },
|
||||
{ -5.17676202387167, 3.486280073084009 },
|
||||
{ -0.8232665608471817, 1.035856623121346 },
|
||||
{ -2.664598562579467, 4.969780569462966 },
|
||||
{ -1.7320549381441652, 0.5626102308837451 },
|
||||
{ -3.3030769989674384, 1.2611477988721695 },
|
||||
{ -2.978115812942412, 3.0819389792053005 },
|
||||
{ 4.061270197659891, 10.977521917377931 }
|
||||
{ 6.259990922080121, 11.972954175355897 },
|
||||
{ -2.5296544304801847, 1.0031292519854365 },
|
||||
{ 0.49037886081440396, 0.9758251727325711 },
|
||||
{ 5.022970993312015, 9.289348879616787 },
|
||||
{ -1.686183146603914, 2.007244382745706 },
|
||||
{ -1.4729253946002685, 2.762166644212484 },
|
||||
{ 4.329788143963888, 11.514016497132253 },
|
||||
{ 3.008674596114442, 4.960246550446107 },
|
||||
{ 3.342379304090846, 5.937630105198625 },
|
||||
{ 2.6993068328674754, 7.42190871572571 },
|
||||
{ -2.446569340219571, 1.9687117791378763 },
|
||||
{ 1.922417883170056, 4.917616702617099 },
|
||||
{ -1.1969741543898518, 2.4576126277884387 },
|
||||
{ 2.4216948702967196, 8.227710158117134 },
|
||||
{ 6.701424725804463, 9.098666475042428 },
|
||||
{ 2.9890253545698964, 9.643807939324331 },
|
||||
{ 0.7162632354907799, 8.978811120287553 },
|
||||
{ -2.7548699149775877, 4.1354812280794215 },
|
||||
{ 8.304528180745018, 11.602319388898287 },
|
||||
{ -2.7633253389165926, 2.786173883989795 },
|
||||
{ 1.3322228389460813, 5.447481218602913 },
|
||||
{ -1.8120096092851508, 1.605624499560037 },
|
||||
{ 3.6546253437206504, 8.195304526564376 },
|
||||
{ -2.312349539658588, 1.868941220444169 },
|
||||
{ -1.882322136356522, 2.033795570464242 },
|
||||
{ 4.562770714939441, 7.414967958885031 },
|
||||
{ 4.731882017875329, 8.890676665580747 },
|
||||
{ 3.492186010427425, 8.9005225241848 },
|
||||
{ -1.619700190174894, 3.314060142479045 },
|
||||
{ 3.5466090064003315, 7.75182101001913 },
|
||||
{ 5.455682472787392, 8.143119287755635 },
|
||||
{ -2.3859602945473197, 1.8826732217294837 },
|
||||
{ 3.9095306088680015, 9.258129209626317 },
|
||||
{ 7.443020189508173, 7.837840713329312 },
|
||||
{ 2.136004873917428, 6.917636475958297 },
|
||||
{ -1.7203379410395119, 2.3212878757611524 },
|
||||
{ 4.618991257611526, 12.095065976419436 },
|
||||
{ -0.4837044029854387, 0.8255970441255125 },
|
||||
{ -4.438938966557163, 4.948666297280241 },
|
||||
{ -0.4539625134045906, 4.700922454655341 },
|
||||
{ 2.1285488271265356, 8.457941480487563 },
|
||||
{ 3.4873561871454393, 11.99809827845933 },
|
||||
{ 4.723049431412658, 7.813095742563365 },
|
||||
{ 1.1245583037967455, 5.20587873556688 },
|
||||
{ 1.3411933634409197, 6.069796875785409 },
|
||||
{ 4.585119332463686, 7.967669543767418 },
|
||||
{ 1.3076522817963823, -0.647431033653445 },
|
||||
{ -1.4449446442803178, 1.9400424267464862 },
|
||||
{ -2.069794456383682, 3.5824162107496544 },
|
||||
{ -0.15959481421417276, 1.5466782303315405 },
|
||||
{ -2.0823081278810136, 3.0914366458581437 },
|
||||
{ 3.521944615248141, 10.276112932926408 },
|
||||
{ 1.0164326704884257, 4.342329556442856 },
|
||||
{ 5.3718868590295275, 8.374761158360922 },
|
||||
{ 0.3673656866959396, 8.75168581694866 },
|
||||
{ -2.250268955954753, 1.4610850300996527 },
|
||||
{ -2.312739727403522, 1.5921126297576362 },
|
||||
{ 3.138993360831055, 6.7338392374947365 },
|
||||
{ 2.6978650950790115, 7.941857288979095 },
|
||||
{ 4.387985088655384, 8.253499976968 },
|
||||
{ -1.8928961721456705, 0.23631082388724223 },
|
||||
{ 4.43509029544109, 8.565290285488782 },
|
||||
{ 4.904728034106502, 5.79936660133754 },
|
||||
{ -1.7640371853739507, 2.7343727594167433 },
|
||||
{ 2.4553674733053463, 7.875871017408807 },
|
||||
{ -2.6478965122565006, 4.465127753193949 },
|
||||
{ 3.493873671142299, 10.443093773532448 },
|
||||
{ 1.1321916197409103, 7.127108479263268 },
|
||||
{ -1.7335075535240392, 2.550629648463023 },
|
||||
{ -0.9772679734368084, 4.377196298969238 },
|
||||
{ 3.6388366973980357, 6.947299283206256 },
|
||||
{ 0.27043799318823325, 6.587978599614367 },
|
||||
{ 5.356782352010253, 7.388957912116327 },
|
||||
{ -0.09187745751354681, 0.23612399246659743 },
|
||||
{ 2.903203580353435, 3.8076727621794415 },
|
||||
{ 5.297014824937293, 8.650985262326508 },
|
||||
{ 4.934508602170976, 9.164571423190052 },
|
||||
{ -1.0004911869654256, 4.797064194444461 },
|
||||
{ 6.782491700298046, 11.852373338280497 },
|
||||
{ 2.8983678524536014, 8.303837362117521 },
|
||||
{ 4.805003269830865, 6.790462904325329 },
|
||||
{ -0.8815799740744226, 1.3015810062131394 },
|
||||
{ 5.115138859802104, 6.376895810201089 },
|
||||
{ 4.301239328205988, 8.60546337560793 },
|
||||
{ 3.276423626317666, 9.889429652591947 },
|
||||
{ -4.001924973153122, 4.3353864592328515 },
|
||||
{ 3.9571892554119517, 4.500569057308562 },
|
||||
{ 4.783067027436208, 7.451125480601317 },
|
||||
{ 4.79065438272821, 9.614122776979698 },
|
||||
{ 2.677655270279617, 6.8875223698210135 },
|
||||
{ -1.3714746289327362, 2.3992153193382437 },
|
||||
{ 3.240136859745249, 7.748339397522042 },
|
||||
{ 5.107885374416291, 8.508324480583724 },
|
||||
{ -1.5830830226666048, 0.9139127045208315 },
|
||||
{ -1.1596156791652918, -0.04502759384531929 },
|
||||
{ -0.4670021307952068, 3.6193633227841624 },
|
||||
{ -0.7026065228267798, 0.4811423031997131 },
|
||||
{ -2.719979836732917, 2.5165041618080104 },
|
||||
{ 1.0336754331123372, -0.34966029029320644 },
|
||||
{ 4.743217291882213, 5.750060115251131 }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue