{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/nearest-neighbor-sampling-based-conditional","title":"Nearest-Neighbor Sampling Based Conditional Independence Testing","arxiv_id":"2304.04183","date":"2023-04-09","proceeding":null,"authors":["Shuai Li","Ziqi Chen","Hongtu Zhu","Christina Dan Wang","Wang Wen"],"abstract":"The conditional randomization test (CRT) was recently proposed to test whether two random variables X and Y are conditionally independent given random variables Z. The CRT assumes that the conditional distribution of X given Z is known under the null hypothesis and then it is compared to the distribution of the observed samples of the original data. The aim of this paper is to develop a novel alternative of CRT by using nearest-neighbor sampling without assuming the exact form of the distribution of X given Z. Specifically, we utilize the computationally efficient 1-nearest-neighbor to approximate the conditional distribution that encodes the null hypothesis. Then, theoretically, we show that the distribution of the generated samples is very close to the true conditional distribution in terms of total variation distance. Furthermore, we take the classifier-based conditional mutual information estimator as our test statistic. The test statistic as an empirical fundamental information theoretic quantity is able to well capture the conditional-dependence feature. We show that our proposed test is computationally very fast, while controlling type I and II errors quite well. Finally, we demonstrate the efficiency of our proposed test in both synthetic and real data analyses.","url_abs":"https://arxiv.org/abs/2304.04183v1","url_pdf":"https://arxiv.org/pdf/2304.04183v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"nearest-neighbor-sampling-based-conditional","repo_url":"https://github.com/LeeShuai-kenwitch/NNSCIT","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"tf","reach":null},{"paper_slug":"nearest-neighbor-sampling-based-conditional","repo_url":"https://github.com/yanfeng-yang-0316/cdcit","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"nearest-neighbor-sampling-based-conditional","repo_url":"https://github.com/MindSpore-scientific-2/code-3/tree/main/the-Soft-Nearest-Neighbor-Loss","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"mindspore","reach":null}],"tasks":[],"methods":[{"method_slug":"test","method_name":"Test"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2304.04183","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2304.04183"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/MindSpore-scientific-2/code-3/tree/main/the-Soft-Nearest-Neighbor-Loss","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/LeeShuai-kenwitch/NNSCIT","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yanfeng-yang-0316/cdcit","reach":null},{"provenance":"deterministic:regex_extraction","url":"https://github.com/LeeShuaikenwitch/NNSCIT","reach":{"status":"gone","observed_at":"2026-09-17","how":"tree_404+repo_404"}}],"summary":{"ran":1,"ran_fixture":7,"ran_draft_wrong":3,"ran_honours":2,"ran_violates":1,"unverified":3},"by_repo_kind":{"official":{"samples":10,"ran":7,"repositories":1},"listed":{"samples":7,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":7,"samples":[{"code_sha256_prefix":"c1217da7a5cae4e9","entry":"Classifier_MI","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c1217da7a5cae4e9"}},{"code_sha256_prefix":"f76c631904de0f95","entry":"NNCMI","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f76c631904de0f95"}},{"code_sha256_prefix":"a4d77d7acb32bcbd","entry":"cmi","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a4d77d7acb32bcbd"}},{"code_sha256_prefix":"ea70a8cbed456c11","entry":"cmiPoint","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ea70a8cbed456c11"}},{"code_sha256_prefix":"f296fd45532342e3","entry":"countNeighbors","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f296fd45532342e3"}},{"code_sha256_prefix":"4fcba4386338d35d","entry":"getKnnDist","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4fcba4386338d35d"}},{"code_sha256_prefix":"8ad2e4cb5226410c","entry":"getPointCoordDists","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8ad2e4cb5226410c"}},{"code_sha256_prefix":"32a3583764c247db","entry":"log_mean_exp_numpy","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"32a3583764c247db"}},{"code_sha256_prefix":"3be01708e9d6e355","entry":"miPoint","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3be01708e9d6e355"}},{"code_sha256_prefix":"574abf7fc64476b5","entry":"mimic_knn","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"574abf7fc64476b5"}},{"code_sha256_prefix":"c6a3311cea14cc5a","entry":"normalize_data","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c6a3311cea14cc5a"}},{"code_sha256_prefix":"99c16e627e3d00e2","entry":"split_XYZ","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"99c16e627e3d00e2"}},{"code_sha256_prefix":"aeb422e5bb499306","entry":"split_train_test","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"aeb422e5bb499306"}},{"code_sha256_prefix":"ae462d71cbe417e2","entry":"xgb_classifier","repo":"yanfeng-yang-0316/cdcit","repo_kind":"listed","path":"nnlscit.py","file_url":"https://github.com/yanfeng-yang-0316/cdcit/blob/HEAD/nnlscit.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ae462d71cbe417e2"}},{"code_sha256_prefix":"e2f76cd7cfe3762c","entry":"CCMI","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e2f76cd7cfe3762c"}},{"code_sha256_prefix":"2bd870923dab2981","entry":"GMCIT","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2bd870923dab2981"}},{"code_sha256_prefix":"8d372150d6881632","entry":"getPairwiseDistArray","repo":"LeeShuai-kenwitch/NNSCIT","repo_kind":"official","path":"nnscit.py","file_url":"https://github.com/LeeShuai-kenwitch/NNSCIT/blob/HEAD/nnscit.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8d372150d6881632"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}