im currently using the following script in an area under curve analysis:
min(data[,2])
to find the min value for my x axis, i would like to create another script which returns the x value where y is at its minimum value?
Cheers
Related
I'm trying to get the middle point of X Y and Weight values, but I didn't found the correct formula to get that.
For example in the picture I've added a few points with a few weights and I need to found the middle point base on the weights.
How about
sum (Wi Xi)/ sum (Wi)
I would like to extract several predicted y-values for the x-values given from this graph :
I know that it is possible to get the x and y coordinates of the curve by using the following function :
coordinate <- ggplot_build(curve)$data[[2]][,c("x","y")]
head(coordinate,n = 6L)
# x y
1 0.1810660 32845.225
2 0.4810660 27635.136
3 0.7553301 23904.792
4 1.3295942 18316.923
5 1.8288582 15092.595
6 5.0312446 8018.707
Is there a function that allows you to directly obtain the predicted value of y for a given x value that does not appear in coordinate such as for example 3.5?
As Gregor mentions, you should fit a model aside of the plot.
Best you can do to "simply" obtain a value otherwise is an interpolating spline
sfun = splinefun(coordinate)
sfun(3.5)
Hi ~ I'm try to make graph which has sample mean on x-axis and
relative frequency(?) on y-axis
to make sure i will give example!
for example when i pick 1sample from c(1,2,3,4,5)
the possible result will be 1 and 2 and 3 and 4 and5
in that case the relative frequency is 1/5 each !!
so in this case my graph will show 1,2,3,4,5 on x-axis
0.2 for y -axis (because they are same in 1/5)
and if i pick 2sample from c(1,2,3,4,5) case would be
(1,2) and (1,3), (1,4), (1,5) (2,3)..... and so on (total 10cases)
so sample mean would be (1+2)/2=1.5 .. (1+3)/2=2 .... etc
so in this case x value will be 1.5, 2 ... etc and y value will
1/10 1/10 ...
so, My question is, is histogram is appropriate for this graph??
i want to plot which have sample mean on x -axis, relative frequency on y-axis
and make a line that connect a dot
sorry for too long question
thanks for reading!!
Yes, it's entirely appropriate to plot a histogram of sample means. This is an example of a sampling distribution.
To do this, you would create an object that contains the sample means, and then just plot a histogram of that object as you would with any other histogram. The value of the sample means would be on the x axis, and frequency or relative frequency on the y axis. You would have to choose an appropriate bin number and breaks vector for your purpose, but it's the same as any other histogram.
I've been working on a proyect and I have to obtain the max value of a plot that I made in PlotlyJS, I need to obtain the frequency of a .wav file and print the musical note associated to that frequency.
http://samcarcagno.altervista.org/blog/basic-sound-processing-julia/
I have been following this post but this only gave you the spectrogram of the frequency. To obtain the fundamental frequency I changed the value of y.
plot(scatter(;x=freqArray/1000, y=p),
Layout(xaxis_title="Frecuencia (kHz)",
xaxis_zeroline=false,
xaxis_showline=true,
xaxis_mirror=true,
yaxis_title="Intensidad (dB)",
yaxis_zeroline=false,
yaxis_showline=true,
yaxis_mirror=true))
That's the plot
Please help me, I don't know how to obtain the frequency
You have two coupled vectors. p contains the value of the intensities, and freqArray contains the matching frequencies. Your plot is displaying a sequence of (x,y) points defined by (freqArray[i],p[i]) for all indices i.
You can use indmax(p) to return the index at which p has the maximal value. Then you can look up what the frequency is by indexing into freqArray at that index.
julia> p = rand(200);
freqArray = 5:5:1000;
julia> idx = indmax(p)
114
julia> p[idx] # this is the maximum value
0.9968329198539723
julia> freqArray[idx] # and this is its frequency
570
If I draw a line from let's say: (2,3) to (42,28), how can I get all points on the line in a Point list? I tried using the slope, but I can't seem to get the hang of it.
To be clear: I would like all the pixels that the line covers. So I can make the line 'clickable'.
This is a math question. The equation of a line is:
y = mx + c
So you need to figure out the gradient (m) and the intercept (c) and then plug in values for x to get values for y.
But what do you mean by "all the points on a line"? There is an infinite number of points if x and y are real numbers.
You can use the formula (x-x1)/(x1-x2) = (y-y1)/(y1-y2). And you know the points with x values ranging from 2 to 42 are on the line and their associated y values have to be found. If any of the resulting y value is not an integer then it should be approximated rightly. And if two consecutive y values differ by more than 1 then the missing y values should be mapped to the last x value.
Here is the pseudo code (tried to capture the crux of the algorithm)
prevY = y1
for(i=x1+1;i<=x2;++i)
{
y = computeY(i);
if(diff(y,prevY)>1) dump_points(prevY,y,i);
prevY = y;
dump_point(i,y);
}
dump_points(prevY,y2,x2);
I am probably not covering all the cases here (esp. not the corner ones). But the idea is that for one value of x there would could be many values of y and vice versa depending on the slope of the line. The algorithm should consider this and generate all the points.