import matplotlib.pyplot as plt
import numpy as np
import torch
# Define your cumulative distribution curve as a list or a tensor
cumulative_curve = [0.1, 0.3, 0.55, 0.8, 1.0] # Example values
x= [0,1, 2,3, 4]
# Define the corresponding y-axis segments
y_segments = [0.2, 0.4, 0.6, 0.8, 1.0] # Example values
# Define the maximum value of the x-axis
N = 4 # Example value
# Convert the cumulative curve to a PyTorch tensor
cumulative_curve_tensor = torch.tensor(cumulative_curve)
# Find the corresponding x-axis segments for each scaled y-axis segment
x_seg = np.interp(y_segments, np.array(cumulative_curve ), np.array(x) )
plt.figure()
plt.plot(cumulative_curve_tensor.numpy().T,label = 'tanh-allJ')
for xc in y_segments:
print('xc = ',xc)
plt.axhline(y=xc, color='gray', linestyle='--')
for yc in list(x_seg):
print('yc= ', yc)
plt.axvline(x=yc, color='gray', linestyle='--')
print("Corresponding x-axis segments:", x_seg)
This code solved my problem. If anybody needs you also can use this one.