Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Basic Math Help

Options
  • 22-06-2012 11:18pm
    #1
    Registered Users Posts: 204 ✭✭


    Hi guys,

    I wonder if anyone could any help me come up with a function for a program im writing?

    So essentially I have 3 groups of customers,

    1. Prefer to buy low priced Items
    3. Prefer to buy high priced Items
    2. Between 1 & 3

    I then have a list of items which can have any price, so I need to work out a % chance of the customer buying the item.

    Examples

    Customer category 1 - Item price €1 = High chance to buy
    Customer category 1 - Item price €100 = low chance to buy
    Customer category 3 - Item price €1 = Low chance to buy
    Customer category 3 - Item price €100 = High chance to buy

    They dont need to be based on the actual amounts, just that the lower the price the more chance customer category 1 will buy it, the higher the price the higher the chance customer category 3 will buy it and 2 being in the middle ground.

    Any help would be appreciated.

    Thanks


Comments

  • Registered Users Posts: 46 naysayer


    ProbToBuy(Customer,Product)
    {
        maxprice = 100; // set your maximum price here or you get probabilities > 1
        
        if (Customer.type == Type1)
        {
            return Product.price/maxprice;
        }
        else if (Customer.type == Type3)
        {
            return 1 - Product.price/maxprice;
        }
        else
        {
            return 1 - ( 2 ( AbsoluteValue ( maxprice/2 - Product.price ) )/maxprice );
        }
    }
    


Advertisement