转换百分比分数最接近 [英] Convert percentage to nearest fraction

查看:169
本文介绍了转换百分比分数最接近的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个非常密集的数据系统。它存储的原始数据,然后计算基础上的正确反应/总试验次数的百分比。

We have a very data intensive system. It stores raw data, then computes percentages based on the number of correct responses / total trials.

谁想要旧数据导入到我们的系统,我们最近有客户。

Recently we have had customers who want to import old data into our system.

我需要一种方法来隐蔽百分比至最接近的部分。

I need a way to covert a percentage to the nearest fraction.

例子。


  1. 33%,需要给我2/6。即使是1/3 0.33333333

  2. 67%,需要给我4/6。即使是4/6 0.6666667

我知道我可以只计算该是67/100,但是这意味着我有100个数据点添加到系统时,6就足够了。

I realize I could just compute that to be 67/100, but that means i'd have to add 100 data points to the system when 6 would suffice.

有没有人有什么想法?

修改
分母可以是任何东西。他们给了我生的,圆润的百分比,我试图得到尽可能接近它原始数据尽可能

EDIT Denominator could be anything. They are giving me a raw, rounded percentage and i'm trying to get as close to it with RAW data as possible

推荐答案

您的要求是矛盾的:一方面,你想的百分比转换为在最近部分(*),但在另一方面,你要小(EST)数字分数。你需要找到一些妥协时/如何有利于更小的数字的下降精度。因为它代表你的问题不解决的。

Your requirements are contradicting: On the one hand, you want to "convert a percentage to the nearest fraction" (*), but on the other hand, you want fractions with small(est) numbers. You need to find some compromise when/how to drop precision in favor of smaller numbers. Your problem as it stands is not solvable.

(*)最近的分数f对于任何给定(整数)率,n为N / 100。每定义。

(*) The nearest fraction f for any given (integer) percentage n is n/100. Per definition.

这篇关于转换百分比分数最接近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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