整数范围的随机子集 [英] Random Subset of Range of Integers

查看:72
本文介绍了整数范围的随机子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了一下,但是找不到任何东西。


我想找一些代码来输入A Range Of的函数br />
整数

例如:函数(1,100);


该函数将返回一个包含随机子集的数组整数

在我指定的大小范围内


所以函数将Probabaly看起来像这样:


std :: vector< int> RandomSubsetOfIntergers(int BeginRanger,int EndRanger,

int SubsetSize);

任何人都知道我可以在这些地方找到什么东西吗?

另外,如果你知道任何一般好的随机数字库快速

并且分布均匀,也让我知道!


谢谢!

-Chris

解决方案

" Chris Dutrow" < CH ****** @ vt.edu>在消息中写道

news:vr ************ @ corp.supernews.com ...

我在网上搜索了有点,但是找不到任何东西。

我想找一些函数代码,我输入一个范围
整数
例如:Function(1 ,100);

并且该函数将返回一个数组,其中包含
整数的随机子集,其大小在我指定的范围内

所以函数将Probabaly看起来像这样:

std :: vector< int> RandomSubsetOfIntergers(int BeginRanger,int EndRanger,
int SubsetSize);




你试过自己实现这个吗?只是好奇,因为这是一个很难解决的问题。


tom


---

外发邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.537 /病毒库:332 - 发布日期:2003年11月6日


我想了一会儿。


我能想到的最好的是O(NlogN)算法一个痛苦

让我来代码。


所以我想我也许不会重新发明轮子并尝试找到一些

由专家编写的代码,他们可能比我更聪明,并且在最优和无问题的解决方案上努力工作




-Chris


" Thomas J. Clancy" < TJ ****** @ comcast.net>在消息中写道

news:r9 ******************** @ comcast.com ...

" ;克里斯杜特罗 < CH ****** @ vt.edu>在消息中写道
新闻:vr ************ @ corp.supernews.com ...

我在网上搜索了一下,不知道但是找不到任何东西。

我想为函数找到一些代码,我输入一个范围
整数
例如:Function(1,100);

该函数将返回一个数组,其中包含一个随机的整数子集

,在我指定的大小范围内

所以函数将Probabaly看起来像这样:

std :: vector< int> RandomSubsetOfIntergers(int BeginRanger,int
EndRanger,int SubsetSize);



你试过自己实现这个吗?只是好奇,因为它是



a要解决的琐碎问题。




---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http:/ /www.grisoft.com)
版本:6.0.537 /病毒库:332 - 发布日期:2003年11月6日



不要在这个NG中担任最高职位


{reformatted}

" Chris Dutrow" < CH ****** @ vt.edu>在消息中写道

news:vr ************ @ corp.supernews.com ...

" Thomas J. Clancy" < TJ ****** @ comcast.net>在消息中写道
新闻:r9 ******************** @ comcast.com ...

" Chris Dutrow" < CH ****** @ vt.edu>在消息中写道
新闻:vr ************ @ corp.supernews.com ...

我在网上搜索了一下,不知道但是找不到任何东西。

我想为函数找到一些代码,我输入一个范围
整数
例如:Function(1,100);

该函数将返回一个数组,其中包含一个随机的整数子集

,在我指定的大小范围内

所以函数将Probabaly看起来像这样:

std :: vector< int> RandomSubsetOfIntergers(int BeginRanger,int EndRanger,int SubsetSize);



你试过自己实现这个吗?只是好奇,因为它



是一个

要解决的小问题。

tom


---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)
版本:6.0.537 /病毒库:332 - 发布日期:2003年11月6日

我想了一会儿。

我能想到的最好的是一个O(NlogN)算法,它将是一个


$ b对我来说代码很痛苦。

所以我想我也许不会重新发明轮子并试着找一些专家写的代码,这些代码可能比我聪明得多在一个优化和无问题的解决方案上努力工作


-Chris




O(NlogN)???

在文档中查找函数rnd - >它返回一个随机的

整数,从0到RAND_MAX


你的功能现在变得微不足道了,不是吗?

我无法阻止不知道,O(NlogN)???

/ dan


I searched around on the net for a bit, couldn''t find anything though.

I would like to find some code for a function where I input A Range Of
Integers
For example: Function( 1, 100 );

And the function will return me an array holding a random subset of integers
in that range of a size that I specify

So the Function would Probabaly look something like this:

std::vector<int> RandomSubsetOfIntergers( int BeginRanger, int EndRanger,
int SubsetSize );
Anyone know where I can find something along these lines?
Also, if you know of any general good random number libratries that are fast
and have an even distribution, let me know as well!

Thanks!
-Chris

解决方案

"Chris Dutrow" <ch******@vt.edu> wrote in message
news:vr************@corp.supernews.com...

I searched around on the net for a bit, couldn''t find anything though.

I would like to find some code for a function where I input A Range Of
Integers
For example: Function( 1, 100 );

And the function will return me an array holding a random subset of integers in that range of a size that I specify

So the Function would Probabaly look something like this:

std::vector<int> RandomSubsetOfIntergers( int BeginRanger, int EndRanger,
int SubsetSize );



Have you tried to implement this on your own? Just curious, because it is a
trivial problem to solve.

tom

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 11/6/2003


I thought about it for a while.

The best I could come up with was an O(NlogN) algorithm that would be a pain
for me to code.

So I figured I might as well not re-invent the wheel and try and find some
code written by experts who are likely much smarter than me and worked hard
on an optimal and bugless solution.

-Chris

"Thomas J. Clancy" <tj******@comcast.net> wrote in message
news:r9********************@comcast.com...

"Chris Dutrow" <ch******@vt.edu> wrote in message
news:vr************@corp.supernews.com...

I searched around on the net for a bit, couldn''t find anything though.

I would like to find some code for a function where I input A Range Of
Integers
For example: Function( 1, 100 );

And the function will return me an array holding a random subset of integers

in that range of a size that I specify

So the Function would Probabaly look something like this:

std::vector<int> RandomSubsetOfIntergers( int BeginRanger, int EndRanger, int SubsetSize );



Have you tried to implement this on your own? Just curious, because it is


a trivial problem to solve.

tom

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 11/6/2003



Don''t top post in this NG

{reformatted}
"Chris Dutrow" <ch******@vt.edu> wrote in message
news:vr************@corp.supernews.com...

"Thomas J. Clancy" <tj******@comcast.net> wrote in message
news:r9********************@comcast.com...

"Chris Dutrow" <ch******@vt.edu> wrote in message
news:vr************@corp.supernews.com...

I searched around on the net for a bit, couldn''t find anything though.

I would like to find some code for a function where I input A Range Of
Integers
For example: Function( 1, 100 );

And the function will return me an array holding a random subset of integers

in that range of a size that I specify

So the Function would Probabaly look something like this:

std::vector<int> RandomSubsetOfIntergers( int BeginRanger, int EndRanger, int SubsetSize );



Have you tried to implement this on your own? Just curious, because it


is a

trivial problem to solve.

tom

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.537 / Virus Database: 332 - Release Date: 11/6/2003

I thought about it for a while.

The best I could come up with was an O(NlogN) algorithm that would be a


pain for me to code.

So I figured I might as well not re-invent the wheel and try and find some
code written by experts who are likely much smarter than me and worked hard on an optimal and bugless solution.

-Chris



O(NlogN)???
Look up in your documentation the function rnd -> it returns a random
integer from 0 to RAND_MAX

Your function becomes trivial now, isnt it?
I just cannot stop wonder, O(NlogN)???
/dan


这篇关于整数范围的随机子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆