Can someone help me to programmatically implement skewed normal distribution fitting on the given data points?
0
0
Entering edit mode
9 months ago
Vijith ▴ 30

My apologies if this question does not fit in this platform. I would appreciate it if any of you, with a solid academic background in mathematics and programming, could provide me with insights and suggestions to tackle this. This question has been posted at Mathematics StackExchange too.

Background

I have been trying to understand the cardiac function of an invertebrate animal. Based on the amplitude values, I plotted a raw graph showing the pattern in which contraction and expansion occur. You may find the raw graph hereimage1. You can find red and green dotted lines. Values beyond the red dotted lines are considered part of an expansion of the heart. Values beyond green dotted lines are considered part of the contraction. I aim to transform the raw graph into a form that looks like an ECG wave.

To achieve this, I have extracted the data points beyond the upper threshold (red-dotted line), lower threshold (green-dotted line), and those within the threshold points, separately.

Data points that are present beyond the upper and lower threshold will be used for generating QRS wavelets. The data points lying within the threshold values are given here.

 [[651.9999999999999, 621.9999999999999, 596.2857142857142], [591.4285714285714, 593.142857142857, 591.9999999999999, 591.9999999999999, 591.9999999999999, 591.9999999999999, 591.9999999999999, 591.9999999999999, 591.9999999999999, 588.5714285714284, 593.7142857142856, 603.9999999999999, 615.9999999999999, 626.2857142857141, 631.4285714285713, 627.9999999999999, 626.5714285714284, 628.7142857142856, 632.9999999999999, 637.9999999999999, 642.2857142857141, 644.4285714285713, 642.6190476190475, 643.190476190476, 644.3333333333331, 645.6666666666664, 646.8095238095236, 647.3809523809522, 646.9999999999998, 646.8095238095236, 647.095238095238, 647.6666666666665, 648.3333333333331, 648.9047619047618, 649.190476190476, 648.9999999999999, 649.190476190476, 648.9047619047617, 648.3333333333331, 647.6666666666664, 647.0952380952378, 646.8095238095236, 646.9999999999998, 646.9999999999998, 646.9999999999998, 646.9999999999998, 646.9999999999998, 646.9999999999998, 646.9999999999998, 646.5238095238093, 647.2380952380951, 648.6666666666665, 650.3333333333331, 651.7619047619046, 652.4761904761904, 651.9999999999999, 651.5238095238094, 652.2380952380951, 653.6666666666665, 655.3333333333331, 656.7619047619046, 657.4761904761903, 655.6666666666665, 657.6666666666665, 661.6666666666665, 666.3333333333333, 670.3333333333333], [669.3809523809523, 639.5714285714284, 614.2380952380951, 601.5238095238094, 609.9999999999999, 616.5714285714284, 606.7142857142856], [591.3333333333331, 618.6666666666664, 642.095238095238, 653.8095238095235, 645.9999999999999, 643.4285714285713, 647.2857142857142, 654.9999999999999, 663.9999999999999], [652.9999999999999, 624.9999999999999, 600.9999999999999, 588.9999999999999, 596.9999999999999, 595.4761904761904, 597.7619047619047, 602.3333333333331, 607.6666666666666, 612.2380952380951, 614.5238095238095, 612.2380952380951, 613.3809523809522, 615.6666666666665, 618.3333333333331, 620.6190476190475, 621.7619047619046, 620.9999999999998, 620.8095238095236, 621.0952380952378, 621.6666666666665, 622.3333333333333, 622.9047619047617, 623.1904761904761, 622.9999999999998, 623.0952380952378, 622.9523809523807, 622.6666666666665, 622.3333333333331, 622.0476190476189, 621.9047619047617, 622.095238095238, 621.9523809523808, 621.6666666666665, 621.3333333333331, 621.0476190476189, 620.9047619047617, 620.9999999999998, 620.8095238095236, 621.0952380952378, 621.6666666666665, 622.3333333333333, 622.9047619047617, 623.1904761904761, 622.9999999999998, 628.238095238095, 620.3809523809522, 604.6666666666665], [592.7619047619046, 596.4761904761903, 593.9999999999998, 592.2857142857141, 594.8571428571427, 599.9999999999998, 605.9999999999998, 611.1428571428569, 613.7142857142856, 611.9999999999998, 610.8571428571427, 612.5714285714284, 615.9999999999999, 619.9999999999999, 623.4285714285713, 625.1428571428571, 623.2380952380952, 624.3809523809523, 626.6666666666665, 629.3333333333333, 631.6190476190475, 632.7619047619046, 631.9999999999998, 631.1428571428569, 632.4285714285712, 634.9999999999999, 637.9999999999999, 640.5714285714284, 641.8571428571428, 640.9999999999999, 640.2380952380952, 641.3809523809523, 643.6666666666665, 646.3333333333333, 648.6190476190475, 649.7619047619046, 648.9999999999999, 648.9999999999999, 648.9999999999999, 648.9999999999999, 648.9999999999999, 648.9999999999999, 648.9999999999999, 648.7142857142856, 649.142857142857, 649.9999999999999, 650.9999999999999, 651.8571428571427, 652.2857142857141, 651.9999999999999, 651.6190476190476, 652.1904761904761, 653.3333333333333, 654.6666666666666, 655.8095238095237, 656.3809523809523, 654.5714285714284, 656.7142857142856, 660.9999999999999, 665.9999999999999, 670.2857142857142], [664.3333333333333, 650.3333333333333, 643.3333333333333, 647.9999999999999, 658.095238095238, 642.9523809523807, 612.6666666666664], [594.3333333333333, 603.6666666666666, 611.6666666666666, 615.6666666666666, 612.9999999999999, 612.5238095238094, 613.2380952380951, 614.6666666666666, 616.3333333333331, 617.7619047619047, 618.4761904761903, 617.9999999999999, 616.6666666666665, 618.6666666666665, 622.6666666666665, 627.3333333333333, 631.3333333333333, 633.3333333333333, 629.2380952380951, 633.3809523809522, 641.6666666666665, 651.3333333333331, 659.6190476190475, 663.7619047619046, 660.9999999999999, 660.0476190476189, 661.4761904761904, 664.3333333333333, 667.6666666666665], [655.9999999999999, 634.5714285714284, 623.8571428571427, 637.6666666666666, 627.6666666666666, 607.6666666666666], [599.3333333333331, 621.3333333333331, 632.3333333333331, 621.3809523809523, 626.8095238095237, 637.6666666666665, 650.3333333333331, 661.190476190476, 666.6190476190474, 662.9999999999998, 661.4761904761903, 663.7619047619045, 668.3333333333331], [667.9999999999998, 658.5714285714283, 653.8571428571427, 666.7142857142856, 652.142857142857, 622.9999999999999, 588.9999999999999], [588.7142857142856, 604.9999999999999, 623.9999999999999, 640.2857142857141, 648.4285714285713, 640.3333333333333, 644.999999999, 646.9999999999999, 628.142857142857, 618.7999999999, 646.9999999999999, 628.142857142857, 618.7142857142854, 631.3809523809523, 621.8095238095237, 602.6666666666665], [590.4285714285714, 595.142857142857, 591.0476190476189, 592.4761904761904, 595.3333333333333, 598.6666666666665, 601.5238095238094, 602.9523809523807, 601.9999999999998, 600.285714285714, 602.8571428571427, 607.9999999999999, 613.9999999999999, 619.142857142857, 621.7142857142857, 619.9999999999999, 617.8095238095237, 621.095238095238, 627.6666666666665, 635.3333333333331, 641.9047619047617, 645.190476190476, 641.190476190476, 643.9047619047618, 649.3333333333331, 655.6666666666665, 661.095238095238, 663.8095238095236, 661.9999999999999, 661.4285714285713, 662.2857142857141, 663.9999999999998, 665.9999999999998, 667.7142857142854, 668.5714285714283, 667.9999999999998, 668.190476190476, 667.9047619047618, 667.3333333333333, 666.6666666666665, 666.095238095238, 665.8095238095237, 665.0476190476189, 666.4761904761904, 669.3333333333333], [669.3333333333333, 662.6666666666666, 656.9523809523808, 654.095238095238, 655.9999999999999, 660.7619047619046, 653.6190476190475, 639.3333333333333, 622.6666666666665, 608.3809523809523, 601.2380952380952, 611.0476190476189, 603.4761904761903, 588.3333333333331], [598.9999999999999, 616.9999999999999, 632.4285714285713, 640.1428571428571, 634.9999999999999, 632.142857142857, 636.4285714285713, 644.9999999999998, 654.9999999999998, 663.5714285714284, 667.8571428571427, 664.9999999999998, 663.7619047619045, 665.6190476190474, 669.3333333333331], [654.6666666666664, 629.3333333333331, 607.6190476190474, 596.7619047619045, 603.9999999999999, 609.047619047619, 601.4761904761904], [594.6666666666665, 616.3333333333333, 634.9047619047618, 644.190476190476, 635.4285714285713, 639.2857142857142, 646.9999999999998, 655.9999999999998, 663.7142857142856, 667.5714285714284, 664.9999999999998, 664.1428571428569, 665.4285714285712, 667.9999999999998], [668.5714285714283, 647.9999999999998, 623.9999999999998, 603.4285714285712, 593.142857142857, 599.9999999999998, 599.3333333333331, 600.3333333333331, 602.3333333333331, 604.6666666666665, 606.6666666666665, 607.6666666666665, 606.9999999999999, 606.7142857142856, 607.142857142857, 607.9999999999999, 608.9999999999999, 609.8571428571427, 610.2857142857141, 609.9999999999999, 609.9999999999999, 609.9999999999999, 609.9999999999999, 609.9999999999999, 609.9999999999999]]

these data points within the thresholds should be used to plot a curve that shows the pattern of distribution of values.

Question

My question is with regard to how I can show the distribution of data points (these are data points within the thresholds, and by the distribution of data points what I mean is that these values are not evenly distributed; some are disproportionately closer to expansion, and some are close to contraction).

What I have done so far

I have tried to apply kernel density estimation (KDE) on each subset of data points, using Seaborn's displot function, as follows.

import seaborn as sns
sns.set_style("whitegrid")  # Setting style(Optional)
plt.figure(figsize = (10,5)) #Specify the size of figure
sns.distplot(x = df["AGW"]   ,  bins = 10 , kde = True , color = 'teal'
            , kde_kws=dict(linewidth = 4 , color = 'black')) #kde for normal distribution
plt.show()

And this generated a curve fitting like thisimage2

Question

I would like to know if there is any other, scientifically more accepted, method for showing the distribution of amplitude values (for the given data points).

I am curious as to how I can implement the skewed normal distribution fitting to the data points, provided. I have read the Wikipedia page for skewed normal distribution, but I don't have sufficient knowledge to find the probability density function of the data points and programmatically implement it to plot the distribution.

I would request someone experienced in this domain to kindly read my query and provide me suggestions/ answers. Kindly, let me know if you need additional information or data.

python probability normal distribution • 477 views
ADD COMMENT

Login before adding your answer.

Traffic: 2549 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6