• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# hqrnd.hqrndstate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中hqrnd.hqrndstate的典型用法代码示例。如果您正苦于以下问题:C# hqrnd.hqrndstate类的具体用法?C# hqrnd.hqrndstate怎么用?C# hqrnd.hqrndstate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



hqrnd.hqrndstate类属于命名空间,在下文中一共展示了hqrnd.hqrndstate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LogisticFit4


//.........这里部分代码省略.........
            int n,
            double cnstrleft,
            double cnstrright,
            bool is4pl,
            double lambdav,
            double epsx,
            int rscnt,
            ref double a,
            ref double b,
            ref double c,
            ref double d,
            ref double g,
            lsfitreport rep)
        {
            int i = 0;
            int k = 0;
            int innerit = 0;
            int outerit = 0;
            int nz = 0;
            double v = 0;
            double b00 = 0;
            double b01 = 0;
            double b10 = 0;
            double b11 = 0;
            double b30 = 0;
            double b31 = 0;
            double[] p0 = new double[0];
            double[] p1 = new double[0];
            double[] p2 = new double[0];
            double[] bndl = new double[0];
            double[] bndu = new double[0];
            double[] s = new double[0];
            double[,] z = new double[0,0];
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
            minlm.minlmstate state = new minlm.minlmstate();
            minlm.minlmreport replm = new minlm.minlmreport();
            int maxits = 0;
            double fbest = 0;
            double flast = 0;
            double flast2 = 0;
            double scalex = 0;
            double scaley = 0;
            double[] bufx = new double[0];
            double[] bufy = new double[0];
            double rss = 0;
            double tss = 0;
            double meany = 0;

            x = (double[])x.Clone();
            y = (double[])y.Clone();
            a = 0;
            b = 0;
            c = 0;
            d = 0;
            g = 0;

            alglib.ap.assert(math.isfinite(epsx), "LogisticFitX: EpsX is infinite/NAN");
            alglib.ap.assert(math.isfinite(lambdav), "LogisticFitX: LambdaV is infinite/NAN");
            alglib.ap.assert(math.isfinite(cnstrleft) || Double.IsNaN(cnstrleft), "LogisticFitX: CnstrLeft is NOT finite or NAN");
            alglib.ap.assert(math.isfinite(cnstrright) || Double.IsNaN(cnstrright), "LogisticFitX: CnstrRight is NOT finite or NAN");
            alglib.ap.assert((double)(lambdav)>=(double)(0), "LogisticFitX: negative LambdaV");
            alglib.ap.assert(n>0, "LogisticFitX: N<=0");
            alglib.ap.assert(rscnt>=0, "LogisticFitX: RsCnt<0");
            alglib.ap.assert((double)(epsx)>=(double)(0), "LogisticFitX: EpsX<0");
            alglib.ap.assert(alglib.ap.len(x)>=n, "LogisticFitX: Length(X)<N");
            alglib.ap.assert(alglib.ap.len(y)>=n, "LogisticFitX: Length(Y)<N");
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:67,代码来源:interpolation.cs


示例2: norm2

        /*************************************************************************
        Generation of random NxN Hermitian positive definite matrix with given
        condition number and norm2(A)=1

        INPUT PARAMETERS:
            N   -   matrix size
            C   -   condition number (in 2-norm)

        OUTPUT PARAMETERS:
            A   -   random HPD matrix with norm2(A)=1 and cond(A)=C

          -- ALGLIB routine --
             04.12.2009
             Bochkanov Sergey
        *************************************************************************/
        public static void hpdmatrixrndcond(int n,
            double c,
            ref complex[,] a)
        {
            int i = 0;
            int j = 0;
            double l1 = 0;
            double l2 = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();

            a = new complex[0,0];

            
            //
            // Special cases
            //
            if( n<=0 || (double)(c)<(double)(1) )
            {
                return;
            }
            a = new complex[n, n];
            if( n==1 )
            {
                a[0,0] = 1;
                return;
            }
            
            //
            // Prepare matrix
            //
            hqrnd.hqrndrandomize(rs);
            l1 = 0;
            l2 = Math.Log(1/c);
            for(i=0; i<=n-1; i++)
            {
                for(j=0; j<=n-1; j++)
                {
                    a[i,j] = 0;
                }
            }
            a[0,0] = Math.Exp(l1);
            for(i=1; i<=n-2; i++)
            {
                a[i,i] = Math.Exp(hqrnd.hqrnduniformr(rs)*(l2-l1)+l1);
            }
            a[n-1,n-1] = Math.Exp(l2);
            
            //
            // Multiply
            //
            hmatrixrndmultiply(ref a, n);
            
            //
            // post-process to ensure that matrix diagonal is real
            //
            for(i=0; i<=n-1; i++)
            {
                a[i,i].y = 0;
            }
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:75,代码来源:linalg.cs


示例3: hmatrixrndmultiply

        public static void hmatrixrndmultiply(ref complex[,] a,
            int n)
        {
            complex tau = 0;
            complex lambdav = 0;
            int s = 0;
            int i = 0;
            complex[] w = new complex[0];
            complex[] v = new complex[0];
            hqrnd.hqrndstate state = new hqrnd.hqrndstate();
            int i_ = 0;

            
            //
            // General case.
            //
            w = new complex[n];
            v = new complex[n+1];
            hqrnd.hqrndrandomize(state);
            for(s=2; s<=n; s++)
            {
                
                //
                // Prepare random normal v
                //
                do
                {
                    for(i=1; i<=s; i++)
                    {
                        hqrnd.hqrndnormal2(state, ref tau.x, ref tau.y);
                        v[i] = tau;
                    }
                    lambdav = 0.0;
                    for(i_=1; i_<=s;i_++)
                    {
                        lambdav += v[i_]*math.conj(v[i_]);
                    }
                }
                while( lambdav==0 );
                
                //
                // Prepare and apply reflection
                //
                creflections.complexgeneratereflection(ref v, s, ref tau);
                v[1] = 1;
                creflections.complexapplyreflectionfromtheright(ref a, tau, ref v, 0, n-1, n-s, n-1, ref w);
                creflections.complexapplyreflectionfromtheleft(ref a, math.conj(tau), v, n-s, n-1, 0, n-1, ref w);
            }
            
            //
            // Second pass.
            //
            for(i=0; i<=n-1; i++)
            {
                hqrnd.hqrndunit2(state, ref tau.x, ref tau.y);
                for(i_=0; i_<=n-1;i_++)
                {
                    a[i_,i] = tau*a[i_,i];
                }
                tau = math.conj(tau);
                for(i_=0; i_<=n-1;i_++)
                {
                    a[i,i_] = tau*a[i,i_];
                }
            }
        }
开发者ID:Ring-r,项目名称:opt,代码行数:66,代码来源:linalg.cs


示例4: hqrndstate

        //
        // Public declarations
        //

        public hqrndstate()
        {
            _innerobj = new hqrnd.hqrndstate();
        }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:8,代码来源:alglibmisc.cs


示例5: cmatrixrndcond

        public static void cmatrixrndcond(int n,
            double c,
            ref complex[,] a)
        {
            int i = 0;
            int j = 0;
            double l1 = 0;
            double l2 = 0;
            hqrnd.hqrndstate state = new hqrnd.hqrndstate();
            complex v = 0;

            a = new complex[0,0];

            ap.assert(n>=1 & (double)(c)>=(double)(1), "CMatrixRndCond: N<1 or C<1!");
            a = new complex[n, n];
            if( n==1 )
            {
                
                //
                // special case
                //
                hqrnd.hqrndrandomize(state);
                hqrnd.hqrndunit2(state, ref v.x, ref v.y);
                a[0,0] = v;
                return;
            }
            l1 = 0;
            l2 = Math.Log(1/c);
            for(i=0; i<=n-1; i++)
            {
                for(j=0; j<=n-1; j++)
                {
                    a[i,j] = 0;
                }
            }
            a[0,0] = Math.Exp(l1);
            for(i=1; i<=n-2; i++)
            {
                a[i,i] = Math.Exp(math.randomreal()*(l2-l1)+l1);
            }
            a[n-1,n-1] = Math.Exp(l2);
            cmatrixrndorthogonalfromtheleft(ref a, n, n);
            cmatrixrndorthogonalfromtheright(ref a, n, n);
        }
开发者ID:Ring-r,项目名称:opt,代码行数:44,代码来源:linalg.cs


示例6: cmatrixrndorthogonalfromtheleft

        public static void cmatrixrndorthogonalfromtheleft(ref complex[,] a,
            int m,
            int n)
        {
            complex tau = 0;
            complex lambdav = 0;
            int s = 0;
            int i = 0;
            int j = 0;
            complex[] w = new complex[0];
            complex[] v = new complex[0];
            hqrnd.hqrndstate state = new hqrnd.hqrndstate();
            int i_ = 0;

            ap.assert(n>=1 & m>=1, "CMatrixRndOrthogonalFromTheRight: N<1 or M<1!");
            if( m==1 )
            {
                
                //
                // special case
                //
                hqrnd.hqrndrandomize(state);
                hqrnd.hqrndunit2(state, ref tau.x, ref tau.y);
                for(j=0; j<=n-1; j++)
                {
                    a[0,j] = a[0,j]*tau;
                }
                return;
            }
            
            //
            // General case.
            // First pass.
            //
            w = new complex[n];
            v = new complex[m+1];
            hqrnd.hqrndrandomize(state);
            for(s=2; s<=m; s++)
            {
                
                //
                // Prepare random normal v
                //
                do
                {
                    for(i=1; i<=s; i++)
                    {
                        hqrnd.hqrndnormal2(state, ref tau.x, ref tau.y);
                        v[i] = tau;
                    }
                    lambdav = 0.0;
                    for(i_=1; i_<=s;i_++)
                    {
                        lambdav += v[i_]*math.conj(v[i_]);
                    }
                }
                while( lambdav==0 );
                
                //
                // Prepare and apply reflection
                //
                creflections.complexgeneratereflection(ref v, s, ref tau);
                v[1] = 1;
                creflections.complexapplyreflectionfromtheleft(ref a, tau, v, m-s, m-1, 0, n-1, ref w);
            }
            
            //
            // Second pass.
            //
            for(i=0; i<=m-1; i++)
            {
                hqrnd.hqrndunit2(state, ref tau.x, ref tau.y);
                for(i_=0; i_<=n-1;i_++)
                {
                    a[i,i_] = tau*a[i,i_];
                }
            }
        }
开发者ID:Ring-r,项目名称:opt,代码行数:78,代码来源:linalg.cs


示例7: init

 public override void init()
 {
     bestparameters = new double[0];
     network = new mlpbase.multilayerperceptron();
     optimizer = new minlbfgs.minlbfgsstate();
     optimizerrep = new minlbfgs.minlbfgsreport();
     wbuf0 = new double[0];
     wbuf1 = new double[0];
     allminibatches = new int[0];
     currentminibatch = new int[0];
     rstate = new rcommstate();
     generator = new hqrnd.hqrndstate();
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:13,代码来源:dataanalysis.cs


示例8: hash

            /*************************************************************************
            This is hash function.

              -- ALGLIB PROJECT --
                 Copyright 14.10.2011 by Bochkanov Sergey
            *************************************************************************/
            private static int hash(int i,
                int j,
                int tabsize)
            {
                int result = 0;
                hqrnd.hqrndstate r = new hqrnd.hqrndstate();

                hqrnd.hqrndseed(i, j, r);
                result = hqrnd.hqrnduniformi(r, tabsize);
                return result;
            }
开发者ID:tablee,项目名称:TabBox,代码行数:17,代码来源:linalg.cs


示例9: dfbuildinternal

        public static void dfbuildinternal(double[,] xy,
            int npoints,
            int nvars,
            int nclasses,
            int ntrees,
            int samplesize,
            int nfeatures,
            int flags,
            ref int info,
            decisionforest df,
            dfreport rep)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            int tmpi = 0;
            int lasttreeoffs = 0;
            int offs = 0;
            int ooboffs = 0;
            int treesize = 0;
            int nvarsinpool = 0;
            bool useevs = new bool();
            dfinternalbuffers bufs = new dfinternalbuffers();
            int[] permbuf = new int[0];
            double[] oobbuf = new double[0];
            int[] oobcntbuf = new int[0];
            double[,] xys = new double[0,0];
            double[] x = new double[0];
            double[] y = new double[0];
            int oobcnt = 0;
            int oobrelcnt = 0;
            double v = 0;
            double vmin = 0;
            double vmax = 0;
            bool bflag = new bool();
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
            int i_ = 0;
            int i1_ = 0;

            info = 0;

            
            //
            // Test for inputs
            //
            if( (((((npoints<1 || samplesize<1) || samplesize>npoints) || nvars<1) || nclasses<1) || ntrees<1) || nfeatures<1 )
            {
                info = -1;
                return;
            }
            if( nclasses>1 )
            {
                for(i=0; i<=npoints-1; i++)
                {
                    if( (int)Math.Round(xy[i,nvars])<0 || (int)Math.Round(xy[i,nvars])>=nclasses )
                    {
                        info = -2;
                        return;
                    }
                }
            }
            info = 1;
            
            //
            // Flags
            //
            useevs = flags/dfuseevs%2!=0;
            
            //
            // Allocate data, prepare header
            //
            treesize = 1+innernodewidth*(samplesize-1)+leafnodewidth*samplesize;
            permbuf = new int[npoints-1+1];
            bufs.treebuf = new double[treesize-1+1];
            bufs.idxbuf = new int[npoints-1+1];
            bufs.tmpbufr = new double[npoints-1+1];
            bufs.tmpbufr2 = new double[npoints-1+1];
            bufs.tmpbufi = new int[npoints-1+1];
            bufs.sortrbuf = new double[npoints];
            bufs.sortrbuf2 = new double[npoints];
            bufs.sortibuf = new int[npoints];
            bufs.varpool = new int[nvars-1+1];
            bufs.evsbin = new bool[nvars-1+1];
            bufs.evssplits = new double[nvars-1+1];
            bufs.classibuf = new int[2*nclasses-1+1];
            oobbuf = new double[nclasses*npoints-1+1];
            oobcntbuf = new int[npoints-1+1];
            df.trees = new double[ntrees*treesize-1+1];
            xys = new double[samplesize-1+1, nvars+1];
            x = new double[nvars-1+1];
            y = new double[nclasses-1+1];
            for(i=0; i<=npoints-1; i++)
            {
                permbuf[i] = i;
            }
            for(i=0; i<=npoints*nclasses-1; i++)
            {
                oobbuf[i] = 0;
            }
            for(i=0; i<=npoints-1; i++)
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例10: mlprandomize

        /*************************************************************************
        Randomization of neural network weights

          -- ALGLIB --
             Copyright 06.11.2007 by Bochkanov Sergey
        *************************************************************************/
        public static void mlprandomize(multilayerperceptron network)
        {
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int ntotal = 0;
            int istart = 0;
            hqrnd.hqrndstate r = new hqrnd.hqrndstate();
            int entrysize = 0;
            int entryoffs = 0;
            int neuronidx = 0;
            int neurontype = 0;
            double vmean = 0;
            double vvar = 0;
            int i = 0;
            int n1 = 0;
            int n2 = 0;
            double desiredsigma = 0;
            int montecarlocnt = 0;
            double ef = 0;
            double ef2 = 0;
            double v = 0;
            double wscale = 0;

            hqrnd.hqrndrandomize(r);
            mlpproperties(network, ref nin, ref nout, ref wcount);
            ntotal = network.structinfo[3];
            istart = network.structinfo[5];
            desiredsigma = 0.5;
            montecarlocnt = 20;
            
            //
            // Stage 1:
            // * Network.Weights is filled by standard deviation of weights
            // * default values: sigma=1
            //
            for(i=0; i<=wcount-1; i++)
            {
                network.weights[i] = 1.0;
            }
            
            //
            // Stage 2:
            // * assume that input neurons have zero mean and unit standard deviation
            // * assume that constant neurons have zero standard deviation
            // * perform forward pass along neurons
            // * for each non-input non-constant neuron:
            //   * calculate mean and standard deviation of neuron's output
            //     assuming that we know means/deviations of neurons which feed it
            //     and assuming that weights has unit variance and zero mean.
            // * for each nonlinear neuron additionally we perform backward pass:
            //   * scale variances of weights which feed it in such way that neuron's
            //     input has unit standard deviation
            //
            // NOTE: this algorithm assumes that each connection feeds at most one
            //       non-linear neuron. This assumption can be incorrect in upcoming
            //       architectures with strong neurons. However, algorithm should
            //       work smoothly even in this case.
            //
            // During this stage we use Network.RndBuf, which is grouped into NTotal
            // entries, each of them having following format:
            //
            // Buf[Offset+0]        mean value of neuron's output
            // Buf[Offset+1]        standard deviation of neuron's output
            // 
            //
            //
            entrysize = 2;
            apserv.rvectorsetlengthatleast(ref network.rndbuf, entrysize*ntotal);
            for(neuronidx=0; neuronidx<=ntotal-1; neuronidx++)
            {
                neurontype = network.structinfo[istart+neuronidx*nfieldwidth+0];
                entryoffs = entrysize*neuronidx;
                if( neurontype==-2 )
                {
                    
                    //
                    // Input neuron: zero mean, unit variance.
                    //
                    network.rndbuf[entryoffs+0] = 0.0;
                    network.rndbuf[entryoffs+1] = 1.0;
                    continue;
                }
                if( neurontype==-3 )
                {
                    
                    //
                    // "-1" neuron: mean=-1, zero variance.
                    //
                    network.rndbuf[entryoffs+0] = -1.0;
                    network.rndbuf[entryoffs+1] = 0.0;
                    continue;
                }
                if( neurontype==-4 )
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例11: duplicates

        /*************************************************************************
        This function selects initial centers according to specified initialization
        algorithm.

        IMPORTANT: this function provides no  guarantees  regarding  selection  of
                   DIFFERENT  centers.  Centers  returned  by  this  function  may
                   include duplicates (say, when random sampling is  used). It  is
                   also possible that some centers are empty.
                   Algorithm which uses this function must be able to deal with it.
                   Say, you may want to use FixCenters() in order to fix empty centers.

        INPUT PARAMETERS:
            XY          -   dataset, array [0..NPoints-1,0..NVars-1].
            NPoints     -   points count
            NVars       -   number of variables, NVars>=1
            InitAlgo    -   initialization algorithm:
                            * 0 - automatic selection of best algorithm
                            * 1 - random selection
                            * 2 - k-means++
                            * 3 - fast-greedy init
                            *-1 - first K rows of dataset are used (debug algorithm)
            K           -   number of centers, K>=1
            CT          -   possibly preallocated output buffer, resized if needed
            InitBuf     -   internal buffer, possibly unitialized instance of
                            APBuffers. It is recommended to use this instance only
                            with SelectInitialCenters() and FixCenters() functions,
                            because these functions may allocate really large storage.
            UpdatePool  -   shared pool seeded with instance of APBuffers structure
                            (seed instance can be unitialized). Used internally with
                            KMeansUpdateDistances() function. It is recommended
                            to use this pool ONLY with KMeansUpdateDistances()
                            function.

        OUTPUT PARAMETERS:
            CT          -   set of K clusters, one per row
            
        RESULT:
            True on success, False on failure (impossible to create K independent clusters)

          -- ALGLIB --
             Copyright 21.01.2015 by Bochkanov Sergey
        *************************************************************************/
        private static void selectinitialcenters(double[,] xy,
            int npoints,
            int nvars,
            int initalgo,
            int k,
            ref double[,] ct,
            apserv.apbuffers initbuf,
            alglib.smp.shared_pool updatepool)
        {
            int cidx = 0;
            int i = 0;
            int j = 0;
            double v = 0;
            double vv = 0;
            double s = 0;
            int lastnz = 0;
            int ptidx = 0;
            int samplesize = 0;
            int samplescntnew = 0;
            int samplescntall = 0;
            double samplescale = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
            int i_ = 0;

            hqrnd.hqrndrandomize(rs);
            
            //
            // Check parameters
            //
            alglib.ap.assert(npoints>0, "SelectInitialCenters: internal error");
            alglib.ap.assert(nvars>0, "SelectInitialCenters: internal error");
            alglib.ap.assert(k>0, "SelectInitialCenters: internal error");
            if( initalgo==0 )
            {
                initalgo = 3;
            }
            apserv.rmatrixsetlengthatleast(ref ct, k, nvars);
            
            //
            // Random initialization
            //
            if( initalgo==-1 )
            {
                for(i=0; i<=k-1; i++)
                {
                    for(i_=0; i_<=nvars-1;i_++)
                    {
                        ct[i,i_] = xy[i%npoints,i_];
                    }
                }
                return;
            }
            
            //
            // Random initialization
            //
            if( initalgo==1 )
            {
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例12: kmeansgenerateinternal

        /*************************************************************************
        K-means++ clusterization

        INPUT PARAMETERS:
            XY          -   dataset, array [0..NPoints-1,0..NVars-1].
            NPoints     -   dataset size, NPoints>=K
            NVars       -   number of variables, NVars>=1
            K           -   desired number of clusters, K>=1
            InitAlgo    -   initialization algorithm:
                            * 0 - automatic selection of best algorithm
                            * 1 - random selection of centers
                            * 2 - k-means++
                            * 3 - fast-greedy init
                            *-1 - first K rows of dataset are used
                                  (special debug algorithm)
            MaxIts      -   iterations limit or zero for no limit
            Restarts    -   number of restarts, Restarts>=1
            KMeansDbgNoIts- debug flag; if set, Lloyd's iteration is not performed,
                            only initialization phase.
            Buf         -   special reusable structure which stores previously allocated
                            memory, intended to avoid memory fragmentation when solving
                            multiple subsequent problems:
                            * MUST BE INITIALIZED WITH KMeansInitBuffers() CALL BEFORE
                              FIRST PASS TO THIS FUNCTION!
                            * subsequent passes must be made without re-initialization

        OUTPUT PARAMETERS:
            Info        -   return code:
                            * -3, if task is degenerate (number of distinct points is
                                  less than K)
                            * -1, if incorrect NPoints/NFeatures/K/Restarts was passed
                            *  1, if subroutine finished successfully
            IterationsCount- actual number of iterations performed by clusterizer
            CCol        -   array[0..NVars-1,0..K-1].matrix whose columns store
                            cluster's centers
            NeedCCol    -   True in case caller requires to store result in CCol
            CRow        -   array[0..K-1,0..NVars-1], same as CCol, but centers are
                            stored in rows
            NeedCRow    -   True in case caller requires to store result in CCol
            XYC         -   array[NPoints], which contains cluster indexes
            Energy      -   merit function of clusterization

          -- ALGLIB --
             Copyright 21.03.2009 by Bochkanov Sergey
        *************************************************************************/
        public static void kmeansgenerateinternal(double[,] xy,
            int npoints,
            int nvars,
            int k,
            int initalgo,
            int maxits,
            int restarts,
            bool kmeansdbgnoits,
            ref int info,
            ref int iterationscount,
            ref double[,] ccol,
            bool needccol,
            ref double[,] crow,
            bool needcrow,
            ref int[] xyc,
            ref double energy,
            kmeansbuffers buf)
        {
            int i = 0;
            int j = 0;
            int i1 = 0;
            double e = 0;
            double eprev = 0;
            double v = 0;
            double vv = 0;
            bool waschanges = new bool();
            bool zerosizeclusters = new bool();
            int pass = 0;
            int itcnt = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
            int i_ = 0;

            info = 0;
            iterationscount = 0;
            ccol = new double[0,0];
            crow = new double[0,0];
            xyc = new int[0];
            energy = 0;

            
            //
            // Test parameters
            //
            if( ((npoints<k || nvars<1) || k<1) || restarts<1 )
            {
                info = -1;
                iterationscount = 0;
                return;
            }
            
            //
            // TODO: special case K=1
            // TODO: special case K=NPoints
            //
            info = 1;
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:dataanalysis.cs


示例13: kmeansgenerateinternal

            /*************************************************************************
            K-means++ clusterization

            INPUT PARAMETERS:
                XY          -   dataset, array [0..NPoints-1,0..NVars-1].
                NPoints     -   dataset size, NPoints>=K
                NVars       -   number of variables, NVars>=1
                K           -   desired number of clusters, K>=1
                Restarts    -   number of restarts, Restarts>=1

            OUTPUT PARAMETERS:
                Info        -   return code:
                                * -3, if task is degenerate (number of distinct points is
                                      less than K)
                                * -1, if incorrect NPoints/NFeatures/K/Restarts was passed
                                *  1, if subroutine finished successfully
                CCol        -   array[0..NVars-1,0..K-1].matrix whose columns store
                                cluster's centers
                NeedCCol    -   True in case caller requires to store result in CCol
                CRow        -   array[0..K-1,0..NVars-1], same as CCol, but centers are
                                stored in rows
                NeedCRow    -   True in case caller requires to store result in CCol
                XYC         -   array[NPoints], which contains cluster indexes

              -- ALGLIB --
                 Copyright 21.03.2009 by Bochkanov Sergey
            *************************************************************************/
            public static void kmeansgenerateinternal(double[,] xy,
                int npoints,
                int nvars,
                int k,
                int maxits,
                int restarts,
                ref int info,
                ref double[,] ccol,
                bool needccol,
                ref double[,] crow,
                bool needcrow,
                ref int[] xyc)
            {
                int i = 0;
                int j = 0;
                double[,] ct = new double[0, 0];
                double[,] ctbest = new double[0, 0];
                int[] xycbest = new int[0];
                double e = 0;
                double eprev = 0;
                double ebest = 0;
                double[] x = new double[0];
                double[] tmp = new double[0];
                double[] d2 = new double[0];
                double[] p = new double[0];
                int[] csizes = new int[0];
                bool[] cbusy = new bool[0];
                double v = 0;
                int cclosest = 0;
                double dclosest = 0;
                double[] work = new double[0];
                bool waschanges = new bool();
                bool zerosizeclusters = new bool();
                int pass = 0;
                int itcnt = 0;
                hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
                int i_ = 0;

                info = 0;
                ccol = new double[0, 0];
                crow = new double[0, 0];
                xyc = new int[0];


                //
                // Test parameters
                //
                if (((npoints < k || nvars < 1) || k < 1) || restarts < 1)
                {
                    info = -1;
                    return;
                }

                //
                // TODO: special case K=1
                // TODO: special case K=NPoints
                //
                info = 1;

                //
                // Multiple passes of k-means++ algorithm
                //
                ct = new double[k, nvars];
                ctbest = new double[k, nvars];
                xyc = new int[npoints];
                xycbest = new int[npoints];
                d2 = new double[npoints];
                p = new double[npoints];
                tmp = new double[nvars];
                csizes = new int[k];
                cbusy = new bool[k];
                ebest = math.maxrealnumber;
                hqrnd.hqrndrandomize(rs);
//.........这里部分代码省略.........
开发者ID:B-Rich,项目名称:Compass,代码行数:101,代码来源:dataanalysis.cs


示例14: A


//.........这里部分代码省略.........
                          position

        RESULT:
            If  the  matrix  is  positive-definite,  the  function  returns  True.
            Otherwise, the function returns False. Contents of C is not determined
            in such case.

        NOTE: for  performance  reasons  this  function  does NOT check that input
              matrix  includes  only  finite  values. It is your responsibility to
              make sure that there are no infinite or NAN values in the matrix.

          -- ALGLIB routine --
             16.01.2014
             Bochkanov Sergey
        *************************************************************************/
        public static bool sparsecholeskyx(sparse.sparsematrix a,
            int n,
            bool isupper,
            ref int[] p0,
            ref int[] p1,
            int ordering,
            int algo,
            int fmt,
            sparse.sparsebuffers buf,
            sparse.sparsematrix c)
        {
            bool result = new bool();
            int i = 0;
            int j = 0;
            int k = 0;
            int t0 = 0;
            int t1 = 0;
            double v = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();

            alglib.ap.assert(n>=0, "SparseMatrixCholeskyBuf: N<0");
            alglib.ap.assert(sparse.sparsegetnrows(a)>=n, "SparseMatrixCholeskyBuf: rows(A)<N");
            alglib.ap.assert(sparse.sparsegetncols(a)>=n, "SparseMatrixCholeskyBuf: cols(A)<N");
            alglib.ap.assert(ordering>=-3 && ordering<=0, "SparseMatrixCholeskyBuf: invalid Ordering parameter");
            alglib.ap.assert(algo>=0 && algo<=2, "SparseMatrixCholeskyBuf: invalid Algo parameter");
            hqrnd.hqrndrandomize(rs);
            
            //
            // Perform some quick checks.
            // Because sparse matrices are expensive data structures, these
            // checks are better to perform during early stages of the factorization.
            //
            result = false;
            if( n<1 )
            {
                return result;
            }
            for(i=0; i<=n-1; i++)
            {
                if( (double)(sparse.sparsegetdiagonal(a, i))<=(double)(0) )
                {
                    return result;
                }
            }
            
            //
            // First, determine appropriate ordering:
            // * for SKS inputs, Ordering=-1 is automatically chosen (overrides user settings)
            //
            if( ordering==0 )
            {
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:67,代码来源:linalg.cs


示例15: support


//.........这里部分代码省略.........
              with NRestarts random starts.  Thus,  FoldsCount*NRestarts  networks
              are trained in total.

        NOTE: Rep.RelCLSError/Rep.AvgCE are zero on regression problems.

        NOTE: on classification problems Rep.RMSError/Rep.AvgError/Rep.AvgRelError
              contain errors in prediction of posterior probabilities.
                
          -- ALGLIB --
             Copyright 23.07.2012 by Bochkanov Sergey
        *************************************************************************/
        public static void mlpkfoldcv(mlptrainer s,
            mlpbase.multilayerperceptron network,
            int nrestarts,
            int foldscount,
            mlpreport rep)
        {
            alglib.smp.shared_pool pooldatacv = new alglib.smp.shared_pool();
            mlpparallelizationcv datacv = new mlpparallelizationcv();
            mlpparallelizationcv sdatacv = null;
            double[,] cvy = new double[0,0];
            int[] folds = new int[0];
            double[] buf = new double[0];
            double[] dy = new double[0];
            int nin = 0;
            int nout = 0;
            int wcount = 0;
            int rowsize = 0;
            int ntype = 0;
            int ttype = 0;
            int i = 0;
            int j = 0;
            int k = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();
            int i_ = 0;
            int i1_ = 0;

            if( !mlpbase.mlpissoftmax(network) )
            {
                ntype = 0;
            }
            else
            {
                ntype = 1;
            }
            if( s.rcpar )
            {
                ttype = 0;
            }
            else
            {
                ttype = 1;
            }
            alglib.ap.assert(ntype==ttype, "MLPKFoldCV: type of input network is not similar to network type in trainer object");
            alglib.ap.assert(s.npoints>=0, "MLPKFoldCV: possible trainer S is not initialized(S.NPoints<0)");
            mlpbase.mlpproperties(network, ref nin, ref nout, ref wcount);
            alglib.ap.assert(s.nin==nin, "MLPKFoldCV:  number of inputs in trainer is not equal to number of inputs in network");
            alglib.ap.assert(s.nout==nout, "MLPKFoldCV:  number of outputs in trainer is not equal to number of outputs in network");
            alglib.ap.assert(nrestarts>=0, "MLPKFoldCV: NRestarts<0");
            alglib.ap.assert(foldscount>=2, "MLPKFoldCV: FoldsCount<2");
            if( foldscount>s.npoints )
            {
                foldscount = s.npoints;
            }
            rep.relclserror = 0;
            rep.avgce = 0;
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:67,代码来源:dataanalysis.cs


示例16: init

 public override void init()
 {
     x0 = new double[0];
     x1 = new double[0];
     t = new double[0];
     xbest = new double[0];
     r = new hqrnd.hqrndstate();
     x = new double[0];
     mv = new double[0];
     mtv = new double[0];
     rstate = new rcommstate();
 }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:12,代码来源:linalg.cs


示例17: mlpkfoldsplit

        /*************************************************************************
        Subroutine prepares K-fold split of the training set.

        NOTES:
            "NClasses>0" means that we have classification task.
            "NClasses<0" means regression task with -NClasses real outputs.
        *************************************************************************/
        private static void mlpkfoldsplit(double[,] xy,
            int npoints,
            int nclasses,
            int foldscount,
            bool stratifiedsplits,
            ref int[] folds)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            hqrnd.hqrndstate rs = new hqrnd.hqrndstate();

            folds = new int[0];

            
            //
            // test parameters
            //
            alglib.ap.assert(npoints>0, "MLPKFoldSplit: wrong NPoints!");
            alglib.ap.assert(nclasses>1 || nclasses<0, "MLPKFoldSplit: wrong NClasses!");
            alglib.ap.assert(foldscount>=2 && foldscount<=npoints, "MLPKFoldSplit: wrong FoldsCount!");
            alglib.ap.assert(!stratifiedsplits, "MLPKFoldSplit: stratified splits are not supported!");
            
            //
            // Folds
            //
            hqrnd.hqrndrandomize(rs);
            folds = new int[npoints-1+1];
            for(i=0; i<=npoints-1; i++)
            {
                folds[i] = i*foldscount/npoints;
            }
            for(i=0; i<=npoints-2; i++)
            {
                j = i+hqrnd.hqrnduniformi(rs, npoints-i);
                if( j!=i )
                {
                    k = folds[i];
                    folds[i] = folds[j];
                    folds[j] = k;
                }
            }
        }
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:50,代码来源:dataanalysis.cs


示例18: normestimatorstate

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# hqrndstate类代码示例发布时间:2022-05-24
下一篇:
C# hMailServer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap