Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 8306d99
  • /
  • test
  • /
  • braindt.h
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge Iframe embedding
swh:1:cnt:216bf1a91c6a38a2d7393c92782ae8a059122b3a
directory badge Iframe embedding
swh:1:dir:892f10df507d1f9e5b4f08f94035d8aa1fa69841
revision badge
swh:1:rev:c5b693d0a66e83c9387433b33c0eab481bd4a763
snapshot badge
swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: c5b693d0a66e83c9387433b33c0eab481bd4a763 authored by Wesley Tansey on 08 May 2020, 15:42:20 UTC
Fixed bug in easy that created too large a support for the alternative distribution
Tip revision: c5b693d
braindt.h
#ifndef briandtH 

#define braindtH

#include<iostream>
#include <fstream>
#include<vector>
#include"randomc.h"
#include"stocc.h"

#include<cstring>
using namespace std;
class braindt{
public:
	braindt(int &LX, int &LY, int &LZ,int &Num,char *argv ,vector<int> &Loca,int &PN,vector<double>& est,int &L_hat,int sweep_b, int sweep_r,int sweep_lis,int iter_max);//constructor function of class braindt
	
	double normpdf(double &x, double &mu, double &sigma_sq);// The probability density function of the normal distribution with mean=mu, variance=sigma_sq
    
	bool IsFiniteNumber(double &x);// Judge whether x is a finite numebr
	bool IsNumber(double &x);//Judge whether x is a numebr
    
    
	double sigmasum(vector<double> &p, int begin, int end);//sum of elements of vector p
	double sigmasum(vector<double> &p1, vector<double> &p2, int begin, int end);//sum of elements of the entrywise-product of vectors p1 and p2
	double sigmasum(vector<double> &p1, vector<double> &p2, double p2minus, int begin, int end);//sum of elements of the entrywise-product of vectors p1 and p3 squared, where p3=p2-p2minus
	
    void two_d_var_matrix_inv(ofstream &fileout,int splnumber);//compute the inverse matrix of a 2 by 2 matrix
    void two_d_var_matrix_inv(int splnumber);

	void gem(ofstream &fileout,char* filename);//The Generalized EM Algorithm
    void gem(char* filename);

	void backtrack(ofstream &fileout, StochasticLib1 &rnd2);//The backtracking line search method
    void backtrack(StochasticLib1 &rnd2);
    
    void func(ofstream &fileout,StochasticLib1 &rnd2);//update U and q2 in the Armijo condition
    void func(StochasticLib1 &rnd2);
    
    
    void computeLIS(char* filename);//computing LIS

private:
	static const double TINY;//a very small number to avoid the zero denominator of a fraction

	int Lx,Ly,Lz,N,YbyX;//N=Lx*Ly*Lz is the size of the image grid, and YbyX=Ly*Lx

	vector<double> y;//observed data
    
	vector<int>::iterator loca;// the location of the brain region of interest (ROI) on the Lx*Ly*Lz image grid
    
	int pN;//the number of voxels in the ROI, i.e., the size of loca
    
///////////////////////////////////////////
    
    
	int L;// the number of components in the normal mixture of non-null distribtion 
	
    //parameters in the null distribution; we assume the null is standard normal.
    static const double mu0;//
	static const double sigma0_sq;//
    
    //parameters in the non-null distribution
	vector<double> mu1_hat;
	vector<double> sigma1_sq_hat;
	vector<double> pEll_hat;//the weight for each component
    
    //parameters in the Ising model
	double beta_hat;//parameter for sum of x_s*x_t,where x is the unobservable state
	double h_hat;//parameter for sum of x_s

///////////////////////////////////////////
	
	vector<double> U;// the score function	
	vector<double> I;// the information matrix 
    vector<double> invI;// the inverse information matrix
	
	int swp_b, swp_r,max_iter;//swp_b is the number of burn-in iterations, swp_r is samples from the Gibbs sampler, max_iter is the maximum limit of iterations in GEM.
    

	vector<double> delta;//the regular Newton step
    
	double beta_hat_old, h_hat_old;//previous values for m iteration, i.e., the interations in backtracking method
    
	vector<int> initial;//the initial random field for the gibbs sampler 

	
	vector<double> H_cond_mean;//mean H conditional on observed data
	
	vector<double> H_mean0;//Used to reset H_cond_mean or H_mean to be zeros
	vector<vector<double> > H0;//Used to reset H to be zeros
	vector<double> H_mean;// mean H
	vector<vector<double> > H;//H
	

	
////////////////////
    double log_plikelihood;// sum of exp(-phi^T*H(sample[i])), in the difference in Q_2

    



    //previous values for t iteration, i.e., the interations in GEM
    vector<double> mu1_hat_pre;
	vector<double> sigma1_sq_hat_pre;
	vector<double> pEll_hat_pre;
    
    
    double alam;// the lambda in the Armijo condition
    int stpover;//indicate whether over the max step

double q2,q2_old, delta_q2;// q_2 is log(sum of exp(-phi^T*H(sample[i]))), in the in the difference in Q_2 
     
////////////////////////////////////
    vector<double> LIS;
    int swp_lis;//  the gibbs sample-size for computing LIS
};

#endif




Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top