找回密码
 注册
查看: 2909|回复: 1

如何在udf中使用随机函数

[复制链接]
发表于 2009-4-22 00:09:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我想定义一个欧拉模型中 第二相微粒直径正态分布的程序,但需要使用在0到1之间的随机函数,哪位高人知道产生随机函数的命令阿,或者是方法:
我的代码:不知道对不对,第一次用这个udf
#include "udf.h"
#include "dpm.h"
#include "sg.h"
#include "stdlib.h"
#include "random.h"

DEFINE_PROPERTY(diameter_g, cell, thread)
{
real d;

float mu,sigma;
float r1,r2;
mu=300.0;
sigma=100.0;  
r1=uniform_random();
r2=uniform_random();
d= sqrt(-2*log(r1))*cos(2*M_PI*r2)*sigma+mu ;
return d;

}

提示报错显示:
C:\Documents and Settings\administrteur\Bureau\dd.c: line 24: function "uniform_random" not found (pc=28).
发表于 2009-4-30 12:57:27 | 显示全部楼层
go to CSDN, search random number generation method. r1 and r2 should be random generated number. u will get d follow normal distribution
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表