标题:[求助]一个数学公式的编写
取消只看楼主
dcc3013
Rank: 1
来 自:青海
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-8-26
结帖率:0
已结贴  问题点数:20 回复次数:0 
[求助]一个数学公式的编写

我的公式由于不能在这写出来,我放在附件里了,请大家帮忙解决一下,下面是我原来的代码;我原来的代码中忘了说明Wij是矩阵,所以出了点错,Xi、Xj分别是已知的值,X上面一缸的是X的平均数,n是个数,请大家帮帮,谢谢了

  private double summation()
        {
            double[] x = { 1, 2, 3 };
            double [,] w ={{1,2,3},{4,5,6},{7,8,9}};
            double wxx = 0, wij = 0, x1 = 0, x2 = 0;
            int n = 3, i, j;
            for (i=0; i<n; i++)
            {
                x1 += x[i];
            }
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < n; j++)
                {
                    wxx += w[i, j] * (x[i] - x1) * (x[j] - x1);
                    wij += w[i, j];
                    x2 += Math.Pow((x[i] - x1), 2);
                }
            }
            return n/x2*wxx/wij;
        }
或者带参数:

        private double summation(double[]x,double[,]w,int n)
        {
            double wxx = 0, wij = 0, x1 = 0, x2 = 0;
            int i, j;
            for (i = 0; i < n; i++)
            {
                x1 += x[i];
            }
            for (i = 0; i < n; i++)
            {
                for (j = 0; j < n; j++)
                {
                    wxx += w[i, j] * (x[i] - x1) * (x[j] - x1);
                    wij += w[i, j];
                    x2 += Math.Pow((x[i] - x1), 2);
                }
            }
            return n / x2 * wxx / wij;
        }

QQ.rar (15.96 KB)
搜索更多相关主题的帖子: 公式 
2009-08-12 15:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-282384-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.457448 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved