Cauchy Distribution

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Markup;

namespace cauchy
{    
    public partial class cauchyFrom : Form
    {   
        int i, j; double r;
        double[] value;
        // generate(0,1)interval random number
        Random rd = new Random(Guid.NewGuid().GetHashCode());
        //double uniform(double double int*)        
        public cauchyFrom()
        {
            InitializeComponent();
        }

        double cauchy(double a,double b)
        { //cauchy distribution, no mean, no sigma,
          //but distrubution is continuous function!
            r = rd.NextDouble();
            r =a-b/Math.Tan(Math.PI*r);
            return r;
        }

        private void btCreateData_Click(object sender, EventArgs e)
        {
            double[] value = new double[50];
            double a=5.0, b=1.0,t;
            for (int i = 0; i < value.Length; i++)
            {
                value[i] = 0.0;
            }
            tbPointData.Clear();
            tbDensityData.Clear();
            foreach (var series in chart_PointDistribute.Series)
            {
                series.Points.Clear();
            }

            foreach (var series in chart_MakeCurve.Series)
            {
                series.Points.Clear();
            }
            for (i = 0; i < 10; i++)
            {
                for (j = 0; j < 5; j++)
                {
                    r=cauchy(a, b);                    
                    value[i * 5 + j] = r;
                    this.chart_PointDistribute.Series[0].Points.AddXY(i * 5 + j, r);
                    tbPointData.AppendText((i * 5 + j).ToString() + ": \t" + r.ToString("f6") + "\t\n  ");
                }
            }           
            
            //f(x)=β/Π*(β² +(x-a)²)
            double[] density = new double[50];            
            for (int i = -25; i < 25; i ++){
                density[i + 25] = b/(Math.PI*(Math.Pow(b,2)+Math.Pow(i-a,2)));
            }
            for(int i = -25; i < 25; i++) {
                this.chart_MakeCurve.Series[0].Points.AddXY(i,density[i+25]);
                tbDensityData.AppendText("X is:" + i.ToString("f0")+"\t" + "Density is:"+density[i+25].ToString("f4")+"\t\n");
            }
        }
    }
}

柯西分布C#程序,散点图,柯西分布密度函数资源-CSDN文库

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值