The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Poisson (help needed)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

pegor

Germany
Posts

Posted - 03/04/2005 :  09:24:42 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:win xp

Hi all,

I want to generate some random numbers that have poisson distribution.
Cpyang told me before to use the following code (thanks alot for ur help):


void tt(int nCol = 1)
{
LT_execute("temp=Poisson(1000, 3)");// create 1000 points with mean = 3, result in dataset called temp

Worksheet wks = Project.ActiveLayer();
Dataset dtemp("temp");// dataset temp can be accessed in OC like this
Dataset aa(wks,nCol-1);// col(1), col(2) etc as Dataset
aa = dtemp;
LT_execute("del temp");// best to clean up temp dataset
}


and it worked perfectly, but the problem is that i want to change the mean so many times in the project, so i cant do it by hand each time,and i cant write: ("temp=Poisson(1000, mean)") and give values to mean.

How can i do this?

Thanks in advance,
Pegor

cpyang

USA
1406 Posts

Posted - 03/04/2005 :  09:33:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
here is the modified code,


void tt(int nCol = 1, double dMean = 3.0)
{
string strLT;
strLT.Format("temp=Poisson(1000, %f)", dMean);
LT_execute(strLT);// create 1000 points with mean = dMean, result in dataset called temp

Worksheet wks = Project.ActiveLayer();
Dataset dtemp("temp");// dataset temp can be accessed in OC like this
Dataset aa(wks,nCol-1);// col(1), col(2) etc as Dataset
aa = dtemp;
LT_execute("del temp");// best to clean up temp dataset
}





CP


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000