Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fitting data to a curve
#1
Coding newbie here!

I'm trying to fit data to a 2d6 probability, with a couple of caveats.

data
input = { “Blue”: 10.46, “Orange”: 0.57, “Red”: 15.27, “Yellow”: 49.87, “Green”: 3.13:, “Purple”: 20.77 }

2d6 curve
curve = { 2: 2.77, 3: 5.55: , 4: 8.33, 5: 11.11, 6: 13.88, 7: 16.66, 8: 13.88, 9: 11.11, 10: 8.33, 11: 5.55, 12: 2.77 }

Since the input values don't already match the curve values, I need to divide them up. For example, Yellow (49.87) should probably be fitted to 7, 8, 9 and 10 (16.66+13.88+11.11+8.33 = 49.98).

Sometimes there will be more or fewer values in input, but they will always add up to (about) 100. Each point on the curve can only be used once.

The expected output looks something like:

2: Orange
3: Red
4: Yellow
5: Blue
6: Yellow
7: Yellow
8: Purple
9: Red
10: Yellow
11: Purple
12: Green

How would you go about this?
Reply
#2
>>> import more_itertools as mit
>>> 
>>> sum(mit.ilen(mit.set_partitions(range(2, 13), k)) for k in range(1, 7))
601492
There are 601_492 ways to partition a 11 elements set into at most 6 subsets. For each of these partitions, you could compute the 2d6 score of each subset, which gives you at most 6 numbers. You could then choose a color for each of these numbers and try to minimize a global score such as a least square difference in doing so.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Learning curve astral_travel 3 443 Apr-05-2024, 06:58 PM
Last Post: jefsummers
  How can I design shapes on a curve in python? mervea 2 823 Sep-14-2023, 01:04 PM
Last Post: Pedroski55
  Returning values from Gaussian fitting Laplace12 0 1,583 Aug-05-2021, 08:09 AM
Last Post: Laplace12
  Find factor to match test curve to golden curve SriRajesh 0 1,566 Jun-17-2021, 04:39 AM
Last Post: SriRajesh
  Fitting Gaussian curve to data file Laplace12 0 2,767 Jun-09-2021, 10:45 AM
Last Post: Laplace12
  search of a curve fitting function bluffy5 2 2,438 Dec-13-2020, 09:53 AM
Last Post: ndc85430
  Scipy kolmogorov smirnov test for evaluating the fitting of a non-normal distribution mcva 0 1,997 May-26-2020, 12:01 PM
Last Post: mcva
  Smooth curve in matplotlib medatib531 0 1,836 Apr-02-2020, 08:07 PM
Last Post: medatib531
  Import Text, output curve geometry Alyner 0 1,992 Feb-03-2020, 03:05 AM
Last Post: Alyner
  How to fix a parameter while fitting klagyi 0 2,209 May-07-2018, 09:58 AM
Last Post: klagyi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020