• 请不要在回答技术问题时复制粘贴 AI 生成的内容
Dcynsd
V2EX  ›  程序员

请教一下各位大佬概率算法问题?

  •  
  •   Dcynsd · Aug 4, 2020 · 2246 views
    This topic created in 2291 days ago, the information mentioned may be changed or developed.

    一件商品原价 10 元,用户可以输入任意 10 元以内价格进行讲价,根据算法判定是否讲价成功。

    已知商品设置了最低价 5 元,如果用户输入的价格在 5 元以下,不会成功,在 5 元以上,那么几率就是离 5 元越近,几率越低,反之几率越大。

    算法渣想了很久没想明白,希望各位能给个建议指导一下,谢谢大家了!

    8 replies  •  2020-08-04 11:42:37 +08:00
    BreadKiller
    BreadKiller
    Aug 4, 2020❤️1
    1
    orginPrice = 10;
    minPrice = 5;
    input = 0;
    chance = (input - minPrice) / (orginPrice - minPrice)
    再加一些大小判断一下就好了
    binux
    binux
    Aug 4, 2020 via Android
    2
    你需要一条概率曲线,否则直接线性就完了
    shpkng
    shpkng
    Aug 4, 2020
    3
    怎么觉得这就是个初中的问题
    Dcynsd
    Dcynsd
    OP
    Aug 4, 2020
    4
    @BreadKiller
    @binux
    感谢回复,有一些思路了
    tfdetang
    tfdetang
    Aug 4, 2020
    5
    if randint(5, 10) =< userinput:
    return True
    else:
    return False
    imkuang
    imkuang
    Aug 4, 2020
    6
    这,,,有什么复杂的地方吗?
    没有什么其他要求的话直接线性怼上去:y=(x-5)/(10-5),x 是输入的价格,y 是机率
    在加些定义域,分一下段:x 取(0,5]的时候 y=0,x 取(5,10]的时候 y=x/5 -1
    noqwerty
    noqwerty
    Aug 4, 2020
    7
    没有其他限制条件的话你的 pdf 直接用 (5, 0) 到 (10, 0.4) 的一条直线不就行了
    GrayXu
    GrayXu
    Aug 4, 2020 via Android
    8
    高中没学过基础的概率吗。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2368 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 12:51 · PVG 20:51 · LAX 04:51 · JFK 07:51
    ♥ Do have faith in what you're doing.