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

C# hqrndstate类代码示例

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

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



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

示例1: hqrndseed

        /*************************************************************************
        HQRNDState initialization with seed values

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static void hqrndseed(int s1,
            int s2,
            ref hqrndstate state)
        {
            state.s1 = s1%(hqrndm1-1)+1;
            state.s2 = s2%(hqrndm2-1)+1;
            state.v = (double)(1)/(double)(hqrndmax);
            state.magicv = hqrndmagic;
        }
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:15,代码来源:hqrnd.cs


示例2: HQRNDRandomize

        /*************************************************************************
        Random number generator: exponential distribution

        State structure must be initialized with HQRNDRandomize() or HQRNDSeed().

          -- ALGLIB --
             Copyright 11.08.2007 by Bochkanov Sergey
        *************************************************************************/
        public static double hqrndexponential(double lambda,
            ref hqrndstate state)
        {
            double result = 0;

            System.Diagnostics.Debug.Assert((double)(lambda)>(double)(0), "HQRNDExponential: Lambda<=0!");
            result = -(Math.Log(hqrnduniformr(ref state))/lambda);
            return result;
        }
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:17,代码来源:hqrnd.cs


示例3: in

    /*************************************************************************
    This function generates random real number in (0,1),
    not including interval boundaries

    State structure must be initialized with HQRNDRandomize() or HQRNDSeed().

      -- ALGLIB --
         Copyright 02.12.2009 by Bochkanov Sergey
    *************************************************************************/
    public static double hqrnduniformr(hqrndstate state)
    {

        double result = hqrnd.hqrnduniformr(state.innerobj);
        return result;
    }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:15,代码来源:alglibmisc.cs


示例4: HQRNDNormal2

        /*************************************************************************
        Random number generator: normal numbers

        This function generates one random number from normal distribution.
        Its performance is equal to that of HQRNDNormal2()

        State structure must be initialized with HQRNDRandomize() or HQRNDSeed().

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static double hqrndnormal(hqrndstate state)
        {
            double result = 0;
            double v1 = 0;
            double v2 = 0;

            hqrndnormal2(state, ref v1, ref v2);
            result = v1;
            return result;
        }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:21,代码来源:alglibmisc.cs


示例5: hqrndseed

    /*************************************************************************
    HQRNDState initialization with seed values

      -- ALGLIB --
         Copyright 02.12.2009 by Bochkanov Sergey
    *************************************************************************/
    public static void hqrndseed(int s1, int s2, out hqrndstate state)
    {
        state = new hqrndstate();
        hqrnd.hqrndseed(s1, s2, state.innerobj);
        return;
    }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:12,代码来源:alglibmisc.cs


示例6: HQRNDRandomize

    /*************************************************************************
    This function generates random number from continuous  distribution  given
    by finite sample X.

    INPUT PARAMETERS
        State   -   high quality random number generator, must be
                    initialized with HQRNDRandomize() or HQRNDSeed().
            X   -   finite sample, array[N] (can be larger, in this  case only
                    leading N elements are used). THIS ARRAY MUST BE SORTED BY
                    ASCENDING.
            N   -   number of elements to use, N>=1

    RESULT
        this function returns random number from continuous distribution which
        tries to approximate X as mush as possible. min(X)<=Result<=max(X).

      -- ALGLIB --
         Copyright 08.11.2011 by Bochkanov Sergey
    *************************************************************************/
    public static double hqrndcontinuous(hqrndstate state, double[] x, int n)
    {

        double result = hqrnd.hqrndcontinuous(state.innerobj, x, n);
        return result;
    }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:25,代码来源:alglibmisc.cs


示例7: HQRNDRandomize

        /*************************************************************************
        This function generates random integer number in [0, N)

        1. State structure must be initialized with HQRNDRandomize() or HQRNDSeed()
        2. N can be any positive number except for very large numbers:
           * close to 2^31 on 32-bit systems
           * close to 2^62 on 64-bit systems
           An exception will be generated if N is too large.

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static int hqrnduniformi(hqrndstate state,
            int n)
        {
            int result = 0;
            int maxcnt = 0;
            int mx = 0;
            int a = 0;
            int b = 0;

            alglib.ap.assert(n>0, "HQRNDUniformI: N<=0!");
            maxcnt = hqrndmax+1;
            
            //
            // Two branches: one for N<=MaxCnt, another for N>MaxCnt.
            //
            if( n>maxcnt )
            {
                
                //
                // N>=MaxCnt.
                //
                // We have two options here:
                // a) N is exactly divisible by MaxCnt
                // b) N is not divisible by MaxCnt
                //
                // In both cases we reduce problem on interval spanning [0,N)
                // to several subproblems on intervals spanning [0,MaxCnt).
                //
                if( n%maxcnt==0 )
                {
                    
                    //
                    // N is exactly divisible by MaxCnt.
                    //
                    // [0,N) range is dividided into N/MaxCnt bins,
                    // each of them having length equal to MaxCnt.
                    //
                    // We generate:
                    // * random bin number B
                    // * random offset within bin A
                    // Both random numbers are generated by recursively
                    // calling HQRNDUniformI().
                    //
                    // Result is equal to A+MaxCnt*B.
                    //
                    alglib.ap.assert(n/maxcnt<=maxcnt, "HQRNDUniformI: N is too large");
                    a = hqrnduniformi(state, maxcnt);
                    b = hqrnduniformi(state, n/maxcnt);
                    result = a+maxcnt*b;
                }
                else
                {
                    
                    //
                    // N is NOT exactly divisible by MaxCnt.
                    //
                    // [0,N) range is dividided into Ceil(N/MaxCnt) bins,
                    // each of them having length equal to MaxCnt.
                    //
                    // We generate:
                    // * random bin number B in [0, Ceil(N/MaxCnt)-1]
                    // * random offset within bin A
                    // * if both of what is below is true
                    //   1) bin number B is that of the last bin
                    //   2) A >= N mod MaxCnt
                    //   then we repeat generation of A/B.
                    //   This stage is essential in order to avoid bias in the result.
                    // * otherwise, we return A*MaxCnt+N
                    //
                    alglib.ap.assert(n/maxcnt+1<=maxcnt, "HQRNDUniformI: N is too large");
                    result = -1;
                    do
                    {
                        a = hqrnduniformi(state, maxcnt);
                        b = hqrnduniformi(state, n/maxcnt+1);
                        if( b==n/maxcnt && a>=n%maxcnt )
                        {
                            continue;
                        }
                        result = a+maxcnt*b;
                    }
                    while( result<0 );
                }
            }
            else
            {
                
                //
//.........这里部分代码省略.........
开发者ID:KBrus,项目名称:nton-rbm,代码行数:101,代码来源:alglibmisc.cs


示例8: in

        /*************************************************************************
        This function generates random real number in (0,1),
        not including interval boundaries

        State structure must be initialized with HQRNDRandomize() or HQRNDSeed().

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static double hqrnduniformr(hqrndstate state)
        {
            double result = 0;

            result = (double)(hqrndintegerbase(state)+1)/(double)(hqrndmax+2);
            return result;
        }
开发者ID:KBrus,项目名称:nton-rbm,代码行数:16,代码来源:alglibmisc.cs


示例9: hqrndseed

        /*************************************************************************
        HQRNDState initialization with seed values

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static void hqrndseed(int s1,
            int s2,
            hqrndstate state)
        {
            
            //
            // Protection against negative seeds:
            //
            //     SEED := -(SEED+1)
            //
            // We can use just "-SEED" because there exists such integer number  N
            // that N<0, -N=N<0 too. (This number is equal to 0x800...000).   Need
            // to handle such seed correctly forces us to use  a  bit  complicated
            // formula.
            //
            if( s1<0 )
            {
                s1 = -(s1+1);
            }
            if( s2<0 )
            {
                s2 = -(s2+1);
            }
            state.s1 = s1%(hqrndm1-1)+1;
            state.s2 = s2%(hqrndm2-1)+1;
            state.magicv = hqrndmagic;
        }
开发者ID:KBrus,项目名称:nton-rbm,代码行数:33,代码来源:alglibmisc.cs


示例10: make_copy

 public override alglib.apobject make_copy()
 {
     hqrndstate _result = new hqrndstate();
     _result.s1 = s1;
     _result.s2 = s2;
     _result.magicv = magicv;
     return _result;
 }
开发者ID:KBrus,项目名称:nton-rbm,代码行数:8,代码来源:alglibmisc.cs


示例11: hqrndrandomize

        /*************************************************************************
        HQRNDState  initialization  with  random  values  which come from standard
        RNG.

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static void hqrndrandomize(ref hqrndstate state)
        {
            hqrndseed(AP.Math.RandomInteger(hqrndm1), AP.Math.RandomInteger(hqrndm2), ref state);
        }
开发者ID:palefacer,项目名称:TelescopeOrientation,代码行数:11,代码来源:hqrnd.cs


示例12: hqrndrandomize

        /*************************************************************************
        HQRNDState  initialization  with  random  values  which come from standard
        RNG.

          -- ALGLIB --
             Copyright 02.12.2009 by Bochkanov Sergey
        *************************************************************************/
        public static void hqrndrandomize(hqrndstate state)
        {
            hqrndseed(math.randominteger(hqrndm1), math.randominteger(hqrndm2), state);
        }
开发者ID:danmendieta,项目名称:UpiicsaSimulacionSistemas,代码行数:11,代码来源:alglibmisc.cs


示例13: HQRNDNormal

    /*************************************************************************
    Random number generator: normal numbers

    This function generates two independent random numbers from normal
    distribution. Its performance is equal to that of HQRNDNormal()

    State structure must be initialized with HQRNDRandomize() or HQRNDSeed().

      -- ALGLIB --
         Copyright 02.12.2009 by Bochkanov Sergey
    *************************************************************************/
    public static void hqrndnormal2(hqrndstate state, out double x1, out double x2)
    {
        x1 = 0;
        x2 = 0;
        hqrnd.hqrndnormal2(state.innerobj, ref x1, ref x2);
        return;
    }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:18,代码来源:alglibmisc.cs


示例14: hqrndrandomize

    /*************************************************************************
    HQRNDState  initialization  with  random  values  which come from standard
    RNG.

      -- ALGLIB --
         Copyright 02.12.2009 by Bochkanov Sergey
    *************************************************************************/
    public static void hqrndrandomize(out hqrndstate state)
    {
        state = new hqrndstate();
        hqrnd.hqrndrandomize(state.innerobj);
        return;
    }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:13,代码来源:alglibmisc.cs


示例15: hqrndintegerbase

        /*************************************************************************

        L'Ecuyer, Efficient and portable combined random number generators
        *************************************************************************/
        private static int hqrndintegerbase(hqrndstate state)
        {
            int result = 0;
            int k = 0;

            alglib.ap.assert(state.magicv==hqrndmagic, "HQRNDIntegerBase: State is not correctly initialized!");
            k = state.s1/53668;
            state.s1 = 40014*(state.s1-k*53668)-k*12211;
            if( state.s1<0 )
            {
                state.s1 = state.s1+2147483563;
            }
            k = state.s2/52774;
            state.s2 = 40692*(state.s2-k*52774)-k*3791;
            if( state.s2<0 )
            {
                state.s2 = state.s2+2147483399;
            }
            
            //
            // Result
            //
            result = state.s1-state.s2;
            if( result<1 )
            {
                result = result+2147483562;
            }
            return result;
        }
开发者ID:Junaid-Akram,项目名称:5271-Keystroke-Dynamics,代码行数:33,代码来源:alglibmisc.cs



注:本文中的hqrndstate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# iCalDateTime类代码示例发布时间:2022-05-24
下一篇:
C# hqrnd.hqrndstate类代码示例发布时间: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